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

learn more… | top users | synonyms

3
votes
6answers
242 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 ...
9
votes
2answers
112 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
54 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: ...
3
votes
3answers
82 views

PDO insert from check boxes

I've seen so many different ways of doing this all seem very complex and all seem to be done in MySQL. I'm using PDO in my project so I've had a go myself to see what I could come up with. Is this ...
3
votes
3answers
57 views

A PDO connection classto initiate multiple connection and easy access

I've been looking for a way to make the database connection easy available directry from any script, and from inside other classes. And since I tend to have different connections based on what action ...
1
vote
1answer
71 views

Best practice-creating a good PDO connection

I have this code for updating time of login failure.The other parts of the code are stripped and simplified because my question is related to PDO.Here I have a db_config.php and a function to update ...
1
vote
2answers
623 views

Best way to insert multiple rows in MySQL

I am building a store. When a user decides to make a purchase I need to store it in the database ( you don't say? Duh! ) but since the purchase might be of more than 1 item I'm wondering which way is ...
3
votes
1answer
101 views

Managing “Jobs” data in a Database

I've been working in a small page with some easy CRUD. The data I get from the database is getting shown on the page. But the way how i show the data feels a bit off. I guess it can be done in a much ...
3
votes
1answer
54 views

Function to count rows in a database query result

I have written this function that surprisingly works. (I didn't really know what I was doing; just a little experiment.) It is supposed to count rows selected by a PDO query. Is it well written? It ...
8
votes
3answers
345 views

Singleton Database wrapper

Before everybody yells at me about why I wrote a PDO wrapper class, it's to avoid writing try/catch, ...
11
votes
1answer
219 views

Web application for a restaurant

I'm making a web application for a restaurant kind of type. The idea is to administrate the orders and customers. For selecting one of the orders and showing more specific data about it, I have this ...
5
votes
1answer
117 views

PDO Login/Register system I've been working on

I'm relatively new to PHP and programming as whole. I'm sure my code could be better in a lot of ways, most of which I can't fully grasp at the moment. As it stands I'm trying to avoid the general ...
4
votes
2answers
88 views

Simple login system

I'm pretty new to PHP and programming general so I'm quite sure my code is an absolute mess. My goal is to write good code, that others can understand just by looking at it. This is a simple login ...
2
votes
1answer
87 views

Using fewer foreach loops to bind values to parameters in PDO

I want to make a query to order by the IN clause items. I read from another thread that I can use ...
4
votes
1answer
81 views

Admin section - Secure login and authentication

After a lot of back and forth on various sites, reading articles, watching videos etc i still can not figure out the best way to secure my admin section. The ...
6
votes
1answer
72 views

Secure way to store passwords

Here I'm trying to develop a simple framework for my own purpose. I'm using PHP and PDO. But, I'm still worried about my password security codes. Below I have posted my codes. it stored like these in ...
4
votes
1answer
70 views

Random select in two MySQL tables

I wrote a simple AJAX request that performs a random select in two MySQL tables. The thing is, my current script involves connecting to the database and creating a new PDO every time the ...
2
votes
1answer
131 views

AJAX request authentication to PHP script

Recently I started looking at my AJAX call security and found some code that uses tokens, request and referer in an attempt to authenticate the call and stop XSS and CSRF. The AJAX calls are for the ...
4
votes
1answer
175 views

Extendable PDO Wrapper Class

I've created a PDO wrapper. I understand PDO could be used on it's own, and I'm reinventing the wheel as there are solutions like Laravel's Eloquent that would do a better job. I'd like advice on ...
3
votes
1answer
66 views

Login system, PDO and me - Part 2

This is a follow up question to: Login system, PDO and me Is this considered secure for a login script? ...
7
votes
1answer
125 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 ...
3
votes
1answer
223 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. ...
1
vote
3answers
135 views

Security of code snippets

Last time I made a website using PHP, I didn't know of PDO, so someone dropped all my tables. I think I've made an improvement now. I'm sorry if there's a lot to go through, but I want to make sure ...
3
votes
2answers
112 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. ...
4
votes
2answers
151 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 ...
5
votes
1answer
49 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 ...
2
votes
2answers
184 views

Should a PDO object be passed to classes and procedural functions as a parameter?

I've been trying to figure out the best way to manage database connections for a while now and am still unsure of how I should be doing things. I know there are a lot of similar questions on here, but ...
0
votes
1answer
87 views

Is this the right way to write OOP PDO classes? [closed]

I have just begun to work with OOP and I am converting my current project into OOP classes. I have a few questions about this User class. ...
4
votes
1answer
73 views

Entire PDO DB Class

Last time I asked a question here, it was for my select function. In that question, another user stated the way I did it, might not have been safe. So here I am with the entire class. The class I'm ...
4
votes
1answer
142 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 ...
0
votes
1answer
44 views

Add user star function triggering PHPmailer email optimisation

The function below simple allows a logged in user to "star" another user for convenience when trying to find the that user another time. At the moment the function works as it should, it inserts the ...
3
votes
1answer
99 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: ...
1
vote
1answer
129 views

How safe is my MySQL query?

I am using PDO for the first time in my project. In my previous project someone suggested me to use PDO as my queries were wide open to inject. I am pasting a sample code of my project. Can you ...
4
votes
1answer
154 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 ...
1
vote
1answer
76 views

Tag Cloud using 2 queries (one nested), and a foreach loop: Is there a better way?

I have a database that, among other things, stores publications and publication tags. There is a many-to-many relationship between publications and publication tags. Simply put, I query the database ...
3
votes
1answer
68 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
2answers
87 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 ...
5
votes
2answers
129 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. ...
4
votes
1answer
54 views

Evaluation of insert method from within a class using PDO

I am learning PDO. I have a class - User... ...
10
votes
4answers
728 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? ...
4
votes
1answer
79 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 ...
10
votes
2answers
272 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
444 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 ...
4
votes
1answer
293 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 ...
1
vote
1answer
99 views

Is this way of passing a parameter relatively safe? [closed]

I'm still playing with how I want to build the parameter. However, in the end I still want to pass it to the prepare statement the same. Note: $this->dbh is ...
3
votes
1answer
108 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. ...
2
votes
1answer
71 views

Are fetchAll() and for() good choices for my code?

I use the following code: fetchAll and for($mich=0;$mich<10;$mich++). Is this the best way? Is there a better way, either ...
3
votes
2answers
153 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 ...
6
votes
2answers
305 views
7
votes
2answers
105 views

Specific PHP Data Access Class

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 posts and articles out there explaining ...