MySQL rollback with PHP PDO
Roll back a MySQL transaction with the PDO rollBack() function. All that is needed is beginTransaction. Start a transaction and run a query that modifies a table: $db->beginTransaction(); $update =…
Roll back a MySQL transaction with the PDO rollBack() function. All that is needed is beginTransaction. Start a transaction and run a query that modifies a table: $db->beginTransaction(); $update =…
Testing 3 Types of MySQL SELECT and then UPDATE from an API call loops with PHP for speed, efficiency and ability to scale. The idea is needing to select a…
Creating a live search input form that matches the current input against a MySQL database using AJAX and PHP combined. I needed this to suite a “product select” project whereby…
Filtering a MySQL SELECT query based on a DateTime being before, after, within or older than is a common need. It can be done a few ways with plenty of…
MySQL does not have a boolean column type, there is no way to systematically store true/false in a database. Except tinyint comes and saves the day. With tinyint using 1…
A MySQL INSERT on duplicate key UPDATE is an all-round excellent query because if a key already exists it will update set values instead of inserting or returning an error….
Showing a MySQL database tables with their columns, type, keys and more is done using the MySQL SHOW syntax. For the tables SHOW TABLES is used whilst to get the…
PHP PDO is a MySQL handler which uses object orientation. As PDO executes queries with prepared statements it is (with correct usage) safer than MySQLi. Below is the PHP PDO…
How to do a MySQL Inner join combined with a COUNT and GROUP BY. Assuming there are two tables with one having details about “posts” and the other “categories” each…
Counting or checking if your PDO MySQL query found a row relies on one key object called rowCount. rowCount returns the number of rows affected by the last executed query….