14
votes
1answer
14k views

Very simple PHP PDO class

There are many PHP PDO classes out there, agreed. However I find they do not allow for flexibility. So I created one that helps reduce development time as little as it may be but it does the job ...
11
votes
3answers
2k views

PHP PDO Database Abstraction Layer

I'd like to get some feedback on a PHP Database Abstraction Layer I've created. It's a little long, but there really wasn't a way to just post part of it. Here is the base ...
10
votes
4answers
697 views

Is this function vulnerable to SQL injection?

I've this function to list products from database by category. I'm using prepared statements but wouldn't this make it pretty pointless to use them? ...
10
votes
2answers
186 views

Want to check if I am using PDO correctly

So today after few years of not programming in PHP I decided to go back, but to do so I needed to change all MySQL connections. So I want to check if I am using it good. Earlier I used to write ...
8
votes
1answer
175 views

PDO sign up function inserting data into multiple tables

This is a sign up function called on form submission. It firstly inserts key user data into the users table. If successful, secondary data is then inputted into ...
7
votes
5answers
10k views

Database class using PDO

The point of this question I'm actually using it while developing a simple application and it seems to cover all my needs. Also it uses PDO so that we don't really have to worry about SQL Injection. ...
6
votes
2answers
218 views
6
votes
1answer
73 views

Login system, PDO and me

I have run into a bit of a dilemma. Binding user input and building a prepared statement is all well and good, but what if I need the user input as a variable for a compare? Can I just create a ...
5
votes
2answers
134 views

Do you see any flaws in these prepared statements to avoid SQL injection?

I have used this guide to implement prepared statements in order to avoid SQL Injection. I made some tests and no error was shown. However, I would like to ask you if you see any flaw in the code, so ...
5
votes
2answers
317 views

moving from->to: mysql->pdo, md5->pbkdf2, procedural->oop

I'm upgrading/rewriting our online client portal and wondering if my log in page code looks okay so far. during this rewriting/learning process I am upgrading a number of things: PHP 5.2 to 5.3.5, ...
5
votes
2answers
94 views

Preventing SQL Injection in user registration routine

At the moment is my code secure for SQL injections and so forth? I still need to hash passwords and make sure fields are valid and so forth. ...
5
votes
2answers
76 views

Specific PHP Data Access Class review

As part of a fun project to help build my knowledge of PHP. I've written a Data Access Class here to bridge the site to the database. I know there are a lot of ...
5
votes
2answers
352 views

Database method to query

I have a database class that in __construct() initialize a PDO connection and insert the instance into a $db private var. Now i'm working on a method that can be ...
5
votes
1answer
39 views

Secure Functions in a Database Class

I am trying to solve as many issues as possible with my Database Class and bind statements as far as possible without actually doing it in the front-end. The goal is to do all of the heaving lifting ...
5
votes
1answer
2k views

Create a table from MySQL using PHP PDO

I am trying to simply present a table in HTML that is stored in a MySQL database. I would like to use Object Oriented PHP to access and fetch the data for the table. I have spent some time learning ...
5
votes
2answers
3k views

PDO wrapper class

...
5
votes
1answer
363 views

Is there any problem in checking PHP PDO connection this manner?

Is there any problem in checking PHP PDO connection this manner? Is this way reliable? ...
5
votes
1answer
754 views

PHP Login Authentication with BCrypt

So I have a php authentication script and everything works fine. But I'm very unsure about the way I programmed it (i hardcoded some stuff) and I was hoping stack could look through this and point out ...
4
votes
1answer
1k views

How to improve Try…Catch Block for PDO?

I have written a PDO wrapper and a class file like a model. So far, it's looking so good! I am just confuse where I should put Try...Catch block - Would it be ...
4
votes
1answer
51 views

Evaluation of insert method from within a class using PDO

I am learning PDO. I have a class - User... ...
4
votes
1answer
91 views

My simple PDO wrapper class

I made a simple database class and I wanted to know if there are any improvements I could work on as far as readability, efficiency, methods and making it modular goes. Any other suggestions are also ...
4
votes
1answer
2k views

PHP Extending PDO Class

I am trying to convert myself from using mysql extension to using PDO, with that being said I was curious if I am going about this the right way. I have a custom logging system that I built I am ...
4
votes
2answers
656 views

Implementing PDO, code correct so far?

I have decided to go PDO and have started implementing it on one of my webprojects. I have limited programing skills but can usually pull it off with some tutorials and forums. Here is my code this ...
4
votes
1answer
100 views

Image upload script for adding items to a database

I wrote my first simple image upload script that allows users to add items to a database along with pictures of said item. My script takes the images uploaded via a form, processes and resizes them ...
4
votes
1answer
213 views

PDO prepared statement - binding variable number of values

Please let me know if I have over/under explained my question :) HTML table row - the numerals from each id attribute, in this example "408" and "409", are the database tables primary ID numbers, one ...
4
votes
1answer
156 views

Is this code protected against SQL injection attacks?

I'm just wondering if this code is good against SQL injection attacks. I don't know how to check if is good. Also I would like to know if is good how I'm working or this is just bad practice? ...
4
votes
1answer
126 views

Code Reiview for an PHP PDO Queries? is there a better way to do it?

so this is my code for a equipping an item in my game dev't: ...
4
votes
2answers
61 views

Optimizing cron job for sending reminders

The following script is being run with a cron. It runs once a minute to see if there is a reminder that needs to be sent. Should I make this run once every 30 minutes? The choices to send a reminder ...
4
votes
1answer
140 views

Thoughts on organizing code for multiple mysql queries in php scripts

I have a web application where I connect with a MySQL database using PDO and in some scripts there are a lot of queries one after the other which don't necessarily concern the same tables. i.e I will ...
4
votes
1answer
256 views

Please review my PDO Database wrapper

The subject is this small project - PHP/MySQL Database wrapper The three main goals of this projects are: Easy way to map database columns to object properties Simple solution to insert or update ...
4
votes
2answers
164 views

Handling access to database connection both inside and outside of classes

Is this an OK way to handle access to database connection both inside and outside of classes? I used to include a PHP file -- database.detl.php -- at the very top of my index.php file containing the ...
3
votes
3answers
5k views

Custom login system (PDO, sanitizing, hash)

I have made a custom login form for my site, with the help of PDO (until now I used simple MySQL connection and sanitizing), and it looks like this: ...
3
votes
2answers
71 views

POST security with PDO?

So I have some code that works as PDO. But is it secure? I'm trying to prevent SQL injection. This is my first PDO script and was hoping to see if it was done correctly. Here it is. ...
3
votes
1answer
73 views

Redunancy Issues in PHP Class

I've been studying PHP for a while now and decided to dive into OOP. Most of my code was a mess and I've begun to refactor much of the website to OOP; however, I'm having an issue with redundancy in ...
3
votes
2answers
68 views

Is this following Separation of Concerns and PHP OOP standards?

I've been working with PHP for a while now, but unfortunately haven't delved into the OO side of it until recently. I've been reading up on separation of concerns and OOP best practices, and I think ...
3
votes
1answer
68 views

My first login class in PHP with PDO and bcrypt

This is the first time using a class. Please review this and tell me if it's secure and if it's the right way to do it. The code itself is working, but I have doubts in the way I used all this. ...
3
votes
1answer
89 views

Is coding to an interface with regards to PDO the right thing to do?

Am I on the right lines for connecting to my Database? If not could somebody help me improve it or point me in the right direction? Index.php: ...
3
votes
1answer
59 views

advantage of using __call method

I have wrote simple class that allowing database selection and inserts.Could you please tell me does this a right way to use __call method with any useful advantage of it ? ...
3
votes
1answer
91 views

Is this a complete PDO prepared class?

Is this class perfect for databases? All I want to know is what I should change to make it perfect. ...
3
votes
1answer
2k views

PDO Login/Register system review

I wrote my very first login/register PDO system today. I know there is still a lot of flaws, but I was wondering what tips and advice you have to help me improve this. I know that PDO is much more ...
3
votes
2answers
1k views

Review my PHP login and register script, and profile page, and how to improve them

There are some things that I know that need to be fixed, such as mysql_* needing to be converted to PDO, and using a better hash. I am working on building a social ...
3
votes
2answers
854 views

PHP PDO Factory Classes

So, my question is more of a 'best practices' question rather than a question with a particular aim. This is my current understanding of PHP factories and how to incorporate them into a project using ...
3
votes
1answer
198 views

Breakable MVC framework written in PHP

I've written a framework in MVC, I call it Midget MVC, as it's so darn small. The reason I wrote it is because I wanted a lightweight and extendible framework to use in projects. It eventually got ...
3
votes
2answers
831 views

How can I improve this PHP MySql Rank generation function?

How can I improve this PHP MySql Rank generation function? (Mostly looking to improve speed, but any feedback is very welcome) Right now I keep stats and ranks in 2 separate tables. The only ...
3
votes
2answers
269 views

Gathering data from database

The following code has one of the most confusing lines I've ever wrote. I can imagine ten other way to write it but I do not know which else could be any better. So I'm here to ask you fellows how ...
3
votes
2answers
149 views

PDO MySQL spaghetti coding

I'm new to this PDO PHP and I have coded this spaghetti style. I hope you can give me idea how to improve using prepared statements. I'm not a lazy person, but I really need your help to improve my ...
3
votes
1answer
104 views

Performance on PHP sql queries

I'm barely learning PHP and MYSQL so I don't know much about performance, I've wrote this script to fetch and format content from my DB, it also counts how many result are and separate them in to ...
3
votes
1answer
196 views

Converting from MySQLi to PDO account activation

I had been working on a project for some time, and then it went on the way back burner after my daughter was born. I'm back to it, and now I discover that I'm best off using PDO over MySQLi. So, I'm ...
3
votes
1answer
1k views

Rewriting the rent system of a building

I'm trying to improve my coding practices and I was just wondering if (I'm definitely sure there are) there are better ways of doing the following task. I'm rewriting the rent system of the building ...