All the PHP tutorials โคต๏ธ
-
Return multiple rows in PDO PHP
I show how to return multiple rows in PDO PHP using query or get methods, with a concrete example to loop through your results.
-
Return single row in PDO PHP
Fetch a single row with PDO in PHP using getRow. Grab user details like name and email without overcomplicating your database queries.
-
Return single value in PDO PHP
Stop fetching whole arrays when you only need one string or number. This snippet shows a simple PDO method that returns a single value from any query.
-
Using Bindings in PDO PHP
I show you how to pass dynamic values into PDO SQL queries using placeholders instead of string concatenation to keep your code clean and safe.
-
No more SQL Injections in PDO PHP
I explain how PDO binding stops SQL injection in PHP by safely escaping variables so you can run queries without fear of breaking your app.
-
How to close PDO Connection in PHP
PDO has no close method, so I show you how to kill the connection by setting the variable to null and why lingering statement objects keep it alive.
-
How to undo queries in PHP PDO
I explain how to undo PHP PDO queries using transactions. This covers beginTransaction, rollBack, and which SQL operations like DDL are safe to reverse.
-
Adding new record with PHP PDO
Use PHP PDO exec and lastInsertId to add a record and get its ID. This post shows how to check for errors before printing the new ID to the screen.
-
Listing single row data with PHP PDO
Use PHP PDO to fetch a single database row without wrapping it in an array. I show you how to handle user input safely and avoid common errors.
-
Listing data with PHP PDO
Fetch and loop through database rows with PHP PDO. See a simple example using the query method to list data without writing extra boilerplate.