PDO is a PHP extension that serves as a data access abstraction layer for accessing databases.

learn more… | top users | synonyms

-1
votes
0answers
19 views

Multiple insert tables in pdo [on hold]

I'm working on an project where i need to insert different values in more then one table. Inner join' is only available on a select prepare but i need it on a insert prepare pdo. ...
2
votes
1answer
51 views

Writing PHP PDO bindParameters

Is there a better way to write this? ...
3
votes
1answer
39 views

Extended PDO class for MySQL

I recently started with object oriented programming in PHP and I am wondering if my database class is on the right track. Am I doing something wrong? If so, how can I improve it? Here is the class: ...
5
votes
1answer
51 views

Tools for transferring data from an API to a database

I explain everything on my current code but this question is more general "HOW TO" work correctly with this in this case but even next time. I have 4 methods in my class, each does something but in ...
4
votes
1answer
51 views

Database Session Class

I have made the decision to move the storing of session data from the filesystem to the database. Our application is growing at pace and we are having issues with the load balancer breaking the ...
2
votes
2answers
47 views

Returning the number of records per day

I'm writing a query to get the number of sessions created each day for the past 90 days. I'm currently using a prepared statement to do this - looks something like this: ...
6
votes
2answers
75 views

A class to add and select players within a database

I have a question and want to know if my class is considered object oriented. ...
3
votes
2answers
59 views

Classes, one responsibility principle and magic methods

I am currently building a small application that allows users to create a slideshow, each slideshow consisting of slides that are either videos or images. Although this will be relatively small at ...
3
votes
3answers
216 views

Web page to add a notice, with some validation

I'm displaying multiple queries and if statements. In the if statement, it increments ...
1
vote
1answer
84 views

PDO - configuration, database connection & and using

I'm currently reading a book and watching some tutorials about PHP with MySQL (PDO), but it is not clear where to put certain things - where to put some code, should I put the connection to the ...
0
votes
1answer
33 views

Bind variables in PHP-MySQL

I am using the below code to execute a MySQL query in PHP. ...
0
votes
1answer
87 views

PDO lastInsertId

In my shop system I'm using the PDO lastInsertId to assign the order_id to the products that belongs to it like this: ...
5
votes
1answer
160 views

PDO Insert function using PHP

This code inserts data into the database successfully. I was concerned about whether it is a considered good practise to go about inserting data into the database in this way. Is there something I am ...
3
votes
1answer
118 views

Custom error/fatal error and exception handler in PHP

Introduction I wrote three functions that aims to log errors and exceptions as well as show a user a generic error page. Would appreciate some feedback on it with regards to the PSR standards and if ...
1
vote
1answer
127 views

PHP script to connect to MySQL database using PDO

Introduction I am preparing to use a basic script to cover how you can connect to a MySQL database using PDO. This script is meant for educational purposes (introductory class on PHP/MySQL) and does ...
0
votes
2answers
347 views

MySQL JOIN to JSON array

I'm building a HTTP API and this part should return a JSON list of posts and their attached photos, like this: ...
3
votes
1answer
312 views

PHP class architecture and dependency injection

Let me start off by saying I am not new to PHP or PDO, but very new to OO PHP, and have been struggling to get a firm idea of best practices in my head regarding dependency injection and structuring ...
2
votes
2answers
102 views

PDO Database Auto Table Creator

How can I do the following with less nested loops. How can I output the Table names above their corresponding tables without having to loop. Functions for returning the DB Info: ...
2
votes
1answer
78 views

Fetch entire table from database after validating the table name

I'm creating a database class. It's part academic and part something I may show in an interview. The purpose of this method is to accept a table name as a parameter, check if the PDO Object has been ...
2
votes
1answer
74 views

Retrieving result sets from a MySQL table

This retrieves result sets from a MySQL table. The objective of this function is to correctly retrieve any number of rows (with $sql) from a MySQL table, binding ...
58
votes
3answers
3k views

Shielding your CodeReview on GitHub

In response to a feature-request on meta, I spent a few hours today creating the feature in php. This application adds a review shield to your GitHub repository (or wherever else you want it). It ...
2
votes
1answer
69 views

Function to streamline PDO statements

This function arguably has little use as it's so simple, but I'm writing a web application with a lot of SQL statements littered all over the place and I thought this function might reduce code ...
5
votes
2answers
1k views

Slim API with 3 layer architecture

I'm new to Slim and the three layered approach I'm using below. So far I have the API, a Presentation layer (leaving out for now), a Business Logic Layer, and a Data Access Layer. The code's working, ...
4
votes
0answers
139 views

Write a HTML table from MySQL tables

I have a piece of code that generates some tables: bp_rows: where I take a snapshot of some "headers" for each row of the table. ...
2
votes
2answers
168 views

PDO wrapper with validation

After moving from mysql_ to PDO I created a PDO handling function. Basically this function takes parameters, checks them and returns end result. The thing is that I created this ~1 year ago and ...
2
votes
2answers
67 views

Storing customers' orders

I'm developing a shop system and using this method to store the customers with their respective orders: ...
4
votes
1answer
112 views

Selecting and inserting MySQL records using PDO

This PHP class connects to and queries the database MuSKL. I am a novice, and I ask you to comment on the approach and style of code. ...
4
votes
3answers
67 views

Database select script

Is there any way I could improve this script, such as by writing it in fewer lines (more efficient)? I'm very interested in keeping my code dry and fast! Also, if there is a way to make it more ...
3
votes
1answer
75 views

Handling DB transaction in closure

I think DB transaction should be as small as possible, and close it soon. So I wrote a helper function like 'using' statement in C#. ...
2
votes
1answer
52 views

Placing navigation items into an array

I am looking for better ways to write this code. At the moment it grabs a list of all navigation items and places them into an array (using PDO). However, as you can see, it is using two ...
3
votes
1answer
234 views

Authentication using PDO

I'm new to PDO, so I was wondering if you guys could check over my PDO code for efficiency (and if the PHP can be improved) ...
2
votes
1answer
187 views

Secure login system

The assignment is to create a login system secured for SQL injections and XSS. It's in PHP and I'm using PDO with prepared statements obviously. Which from my point of view should protect against the ...
0
votes
1answer
74 views

Syntax form PDO

I was able to run the form to update the data of the user profile, for the moment is in a rough version, but I know that can be improved. I post what I did, I hope you could help me to improve the ...
2
votes
1answer
323 views

PHP login system security using a database, cookies and sessions

I created a simple login system using just sessions but having to login every time gets annoying. That is why I'm no trying to save the sessions to my database linked to the user's account. I will ...
1
vote
2answers
170 views

PHP PDO Helper Functions

Just recently I've wanted to update the PHP scripts I use to fetch information from a database for an iOS application. I've got around to it today, and I had a few questions that'd I like a second ...
3
votes
1answer
91 views

Checking referential integrity of a database schema

I am using PHP PDOs to parse the results I am receiving from MySQL queries against a database. I am now running into an issue with running out of allocated memory. Are there any suggestions on ...
0
votes
2answers
613 views

Am I correctly implementing PHP/PDO and the MVC/DAO pattern?

Context: I am working on the login module of a PHP web-application and I am trying to implement this using PHP/PDO and the DAO pattern. I would like someone to review the code below and let me know ...
2
votes
1answer
142 views

Class method to insert a record into MySQL

I'm just starting out using OOP; classes and methods etc. I've been looking around for some PDO classes/wrappers out there, but there's not much to choose from. So I've tried to make my own. Started ...
1
vote
1answer
294 views

PHP PDO Database Wrapper

I'm trying to wrap my head around OOP, and am fairly new to PHP in general, so please forgive me if the following makes you cringe. I've decided to try and create a basic database wrapper using PDO. ...
1
vote
1answer
214 views

PHP PDO / MySQL helper/wrapper functions

Further to my previous post for a user login script I've been learning PDO in order to migrate from mysql_* functions. As before with mysql_*, I wanted to wrap the PDO code into wrapper functions, so ...
3
votes
3answers
451 views

PDO class and security

I have started a project in PHP with PDO and I'm almost done, but I've read somewhere that PDO escape alone is not secure and we have to consider some settings of PDP. I am a little confused about my ...
4
votes
2answers
942 views

Voting system for a website

I am currently adding a voting system to my website. Below is my voting class. I feel that it could be simplified and that there is repeated code regarding the functions, although to the best of my ...
1
vote
0answers
79 views

Create and access database connection

I'm working on an MVC project and I'm writing the code for get access to the database connection. I have two files: The first (PdodbLib.class.php) extends PDO: ...
3
votes
1answer
124 views

Custom session handler

I'm new to PDO and haven't been coding in a while. Is the following custom session handler industry-acceptable? ...
4
votes
1answer
52 views

Creating efficient PDO functions

I have the following functions: ...
3
votes
3answers
2k views

Cron PHP script to pull newly added clients from remote db, add their information to local db

I wrote a PHP script and was wondering if it was well written or if it could be improved upon to read or run more efficiently, any help or critique would be greatly appreciated. The file will be ...
1
vote
2answers
53 views

Database fetch class

The active column in the database only contains a boolean. The country column contains ISO 3166 A2 codes (2 char). Do you have any advice on improving this class? ...
2
votes
4answers
184 views

User class and 'generic' Database class

This may be a bit overwhelming, but me and a friend of mine have written a Database class with methods for our queries. All of these queries should be generic so we can use them in multiple ways. We ...
1
vote
2answers
3k views
7
votes
1answer
214 views

Database abstraction layer for PHP web application

I'm working on a PHP based web application. While building the UserStorage class, (which acts as a storage source for user data, and implements the ...