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

learn more… | top users | synonyms

2
votes
1answer
75 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
116 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
82 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
66 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
31 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 ...
3
votes
6answers
362 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
128 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
83 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
89 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
73 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
82 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
1k 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
102 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
61 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
357 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
245 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
148 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
119 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
135 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
174 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
78 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
79 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
170 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
246 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
79 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
132 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
261 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
141 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
132 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
185 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
52 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
328 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
98 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
84 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
185 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
46 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
100 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
137 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 ...
5
votes
1answer
176 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
94 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
70 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 ? ...
2
votes
2answers
95 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
144 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
740 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
323 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
594 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
310 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
106 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 ...