PDO is a PHP extension that serves as a data access abstraction layer for accessing databases.
2
votes
1answer
42 views
Optimize PHP and MySQL with PDO
I am updating some old reports that are using mysql_ statements and trying to use the MySQL PDO stuff. I was told that PDO is far better since I was running into runtime issues with some of my ...
0
votes
1answer
75 views
How can I make this piece of code more secure?
I am using db_dataobject and have provided two examples of an insert and a select query below.
Can you please help me rewrite them in a more secure way using PDO? Is there any other way to improve ...
2
votes
1answer
302 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 ...
1
vote
3answers
125 views
Look over my code for PDO and MVC
I'm building this website with PDO and Pattern MVC. I'm currently working on the login page and would like to know if this structure is correct for MVC pattern. I'd also like your opinions and ...
2
votes
1answer
100 views
Structure pages mvc + oop
I am developing a website and I want to use PDO and MVC.
Before, I was coding in procedural MySQL, but I'm starting to understand the object-oriented programming.
My problem is the following:
If I ...
4
votes
1answer
143 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?
...
1
vote
2answers
81 views
Please review my registration and login
So, I'm fairly new to PHP. I love it. Right now I'm creating a community. You can register and create your own profile and post on a forum etc. I'm just doing this for fun and learning. I'm not ...
0
votes
2answers
36 views
How do I put $db in a central location, but maintain variable scope
I have that $db, that I will use again and again to connect to the database. How do I put this in a central location so if I change my db I will not have to rewrite a bunch of lines of code? ...
1
vote
0answers
45 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.
...
1
vote
1answer
143 views
Creating a PDO abstract parent class
I think many people for some reason use a singleton class to handle the PDO connection (?) but I was thinking it would be nice to have a parent abstract class initializing the connection and the child ...
0
votes
3answers
122 views
Can this code be simplified even further?
Can I make any further improvements to simplify / speed up this code? My reason for creating new arrays for the variables $name, $business, $email, $orderstatus is because when displaying results ...
0
votes
1answer
54 views
Can this code be improved upon?
My code already works 100%, just trying to figure out if there is an easier, better or speedier way to do this. Outputs to an HTML table to display results.
Something that took me a while to figure ...
1
vote
1answer
110 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:
$conn = new PDO('mysql:host=localhost;dbname=work', 'root', ...
3
votes
1answer
72 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
58 views
How do I refactor this basic form handler
I've dabbled with PHP for a couple of years, I can generally get what I need done and I've been teaching myself PDO. The problem is I want to set it up with classes but i'm not really sure how to.
...