Category Archives: db

PHP code snippet – Reorder items in a table

This snippet of code reorders items in a table based on the number of steps you want to move an item from its current position. It moves the item of interest to its new position and shifts all other items to their new shifted positions. PLAIN TEXT PHP: function moveItem ($n_steps) { if ($n_steps == [...]

PDO – initialising a MySQL connection

PHP Data Objects (PDO) is a PHP extension that provides a consistent interface for database connectivity. This means that it allows your PHP code to talk to a number of different database formats without you having to modify your code for each particular case. This is no different (on the face of it) to other [...]