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

learn more… | top users | synonyms

3
votes
1answer
125 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
37 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: ...
-1
votes
1answer
50 views

MySQL security in PHP

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
56 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 ...
6
votes
0answers
80 views

PDO Class to help on writing SELECT statements

I made this class just for the fun of it. The idea is to make a SELECT statement really quickly. ...
48
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
44 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
175 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
75 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
154 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
57 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
76 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
58 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
47 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
45 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
81 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
104 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
59 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
161 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
65 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
73 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
292 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
108 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
96 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
139 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
227 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
619 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
68 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
107 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
42 views

Creating efficient PDO functions

I have the following functions: ...
3
votes
3answers
844 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
45 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
109 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 ...
7
votes
1answer
198 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 ...
2
votes
1answer
227 views

Uploading images via MySQL in Blob

Is it safe to upload images via MySQL in Blob? I've constructed my code like the following: ...
2
votes
1answer
148 views

Securing a form with image uploads

I am using PDO prepared statements to store user entered input and store that input to the database. The code will store a text input and 5 uploaded images. Will this code protect from data SQL ...
1
vote
1answer
90 views

Handling errors when using PDO to connect to a database instead of MySQLi

What would be the preferred method for handling errors when using the PDO to connect to a MySQL database? I was using mysqli_error($this->pdo), but I heard this ...
4
votes
2answers
121 views

Student status form

I'm programming a system and I want to know if this is the correct way or if there is a better way to do it. Container: I have more fields but I only added one to show you the container. ...
1
vote
2answers
255 views

PDO class extend

I am moving in to OOP PHP and having some problems extending my database class to my objects. I am still new to the variable scoping in OOP PHP, so if it a tiny syntax error I apologize. If my ...
1
vote
0answers
88 views

Folder model controller view

I'm using a slim router and have made a folder model controller view. Below is one of my model files. I made one database with one model. I have some problem in my project: there are several ...
2
votes
2answers
306 views

Small PHP DAO app

I'm creating a small app and decided to write my own DAO for learning, etc. At the moment it's in one big file, which I really don't like. Could you give me some tips on how: you would separate ...
2
votes
1answer
183 views

PDO PHP DB Class

I've been building a PDO PHP DB class and I just wonder if someone could give me some feedback (regarding security, how the code is written and how I can optimize it). This class is not finished ...
3
votes
1answer
385 views

PDO wrapper class for database

I have my PDO Wrapper class and would love to get some more tips/opinions about what you think. This is my first class and I basically put my time into making it as logical and standardized as ...
2
votes
1answer
163 views

Script for a multi-user webapp database connection

I have the following working script which I use for my database connection for a multi-user webapp. I use a different database for the login, this script is called only after the user is successfully ...
3
votes
2answers
150 views

Select products and config values from MySQL

I have working code that gets products details and config values from MySQL bit it's combined with HTML, I would like to know a better way to do this, maybe a class that I can use. ...
2
votes
1answer
35 views

Could this connection and query class be improved?

Wrote this class it allows me to connect to database and display as many columns as I wish to. I can just give it desired parameters and I'm done. I've commented about the parameters that need it to ...
6
votes
6answers
5k views

OOP PDO Database Connection

I'm currently learning about PDO, and trying to connect to the database and CRUD in OOP way, this is a simple code that I use. index.php ...
10
votes
2answers
234 views

PDO connection via INI parser classes

A few days ago I asked this question and I've got an answer to work with interfaces. I've tweaked around with this to get myself a INI parser class. ...
0
votes
1answer
564 views

Nested try/catch with PDO in PHP

I would like to know if this is the correct way to use try/catch when dealing with multiple MySQL queries and PDO: ...