Questions tagged [pdo]

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

Filter by
Sorted by
Tagged with
54
votes
2answers
58k views

Class for reducing development time

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 (...
4
votes
1answer
2k 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 ...
2
votes
1answer
82 views

Connect to database, handling errors

I try to handle or catch possible errors with PHP/MySQL for security reasons and would like to know if I'm doing it right. The first case, connection: I use it as a function and call it always when ...
2
votes
1answer
154 views

Object-oriented PDO wrapper

So, I've recently started learning OOP in PHP and learned $this keyword. I know it's a reference to the current object. So I wrote a class and couple of functions ...
5
votes
3answers
3k views

A demonstrational example of a Data mapper ORM

I want to create an educational example of a Data mapper type ORM. You know, it is always interesting to know how the stuff works, but when you take a fully functional software package, it's just ...
4
votes
1answer
2k views

PDO wrapper class

Connection stored in the xml config file. ...
8
votes
6answers
25k 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 ...
4
votes
2answers
20k views

Simple PDO database class in PHP

I'm writing a simple database class so I could use it in my future projects. It is based on some Codeigniter database methods, but my implementation, so if you could review this, that would be cool. ...
3
votes
2answers
5k views

Saving and uploading images in a database

I am working on a small method that saves uploaded images and records the images in a database. ...
6
votes
1answer
245 views

Password Hashing and SQL Queries

I am new to web development and am working on a portfolio piece, so I would like to make sure I'm not creating obvious vulnerabilities. I am wondering whether there are any clear flaws in the ...
4
votes
2answers
3k 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 ...
4
votes
2answers
704 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 ...
3
votes
1answer
591 views

querySingle function for PDO

I have been refactoring a lot of my old code lately, and with that I have been switching from sqlite3 to mysql using PDO - sqlite3 has something called "querysingle" that allows you to return single ...
2
votes
1answer
3k views

MySQL vs PDO execution time

I'm having some issues understanding why PDO is 6X slower executing a query than the depreciated MySQL query function. Here's my code: ...
1
vote
1answer
13k views

PHP login form with PDO

I create login form with session with four files: connection.php login.php plan.php logout.php Please check my code and tell about any smokestack. Database educate (create table users) ...
1
vote
2answers
4k views

PHP PDO Wrapper

Here's a PHP PDO wrapper class that I wrote, along with example usage. This class features 2 primary methods for interacting with a database: Query(), which returns ...
1
vote
1answer
170 views

Pages system PHP/SQL

I'm working on a CMS, currently on being able to create static pages, manage menus etc. so.. I have This function that reads from the DB and finds all the static pages, and their position in the menu. ...
10
votes
4answers
812 views

Listing products from a database

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? ...
7
votes
1answer
439 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 ...
4
votes
2answers
2k 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
2answers
1k views

Login System using PHP and PDO Prepared Statement

vir.php ...
3
votes
2answers
108 views

warehouse management class code

I'm writing a simple class to manage a warehouse, so it's supposed that it will use a database connection. All works fine for now, and I'm actually working to finish the UI. Since I think to be a ...
3
votes
2answers
3k 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 this ...
3
votes
3answers
2k 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 ...
3
votes
2answers
451 views

Confirming safety of SQL injection

I believe with everyone's help on Stack Overflow, I got my code safe guarded from SQL injection. I'm trying to confirm that is correct, just in case I misinterpreted the help and advice I received. <...
2
votes
1answer
202 views

Registering users bank account and logging in securely

I wrote a php script to register a user's bank account and I've tried to make the login as secure as possible, but I wonder if there are any flaws and is it's free from xss attacks and sql injection ...
2
votes
1answer
211 views

Database interface and PDO adapter

I'm writing my own framework in PHP and I want respect the SOLID principles. I made this interface: ...
2
votes
1answer
68 views

Insert data on Data Base using PDO Prepared Statement

...
2
votes
1answer
515 views

Login system with password reset sent to e-mail using PHP and PDO

I really like to use PDO because it's simple and easy to make a safe query, i prepared all queries and used placeholders, i think it's safe but i'm not sure at all, and I'm thinking if i used ...
1
vote
1answer
59 views

Database connection and DataMapper

Following my previous question Database interface and PDO adapter, I wrote a new simple class to connect to Database and run a query returning a PDO statement. ...
1
vote
1answer
57 views

store and warehouse management class

I've already posted this PHP class few days ago when I started writing it. Now that all the methods and all the controller logics are ready, I will be ask here for some suggestions about how to ...
-1
votes
1answer
2k views

Mysql flexible insert record with bind_param or bind_value

I want to insert rows in a database table with the precaution of SQL-injection. I'm using below flexible MySQL insert function, which enters a record in a given table. Is this the best approach or is ...