Run Multiple MySQL Queries in a Single Function

If you want to be able to run multiple queries in a single function call, for example doing the classic drop table blah; create table blah; then you might like this function. The use case is for things like database migration systems which you might copy and paste chunks of SQL including multiple queries from things like phpMyAdmin /** * Run multiple queries passed in as a single string * Read On →

Cron not Working in Magento +Solution

I recently had a Magento store that was not running cron jobs despite everything appearing to be set up correctly. After tearing out my hair, I discovered that there was a cron job running that had not closed properly, which prevented any new cron jobs from starting. This is because the cron.sh file that is used by magento checks the currently running processes, and if one exists quietly exits. To check if this is the case you can run a modified line from the cron.sh file as set out below ps auxwww | grep “/path/to/magento/cron.php” | grep -v grep | grep -v cron.sh If this returns a line similar to the one below root 2125 0.0 0.9 329896 40484 ? Read On →

Magento Admin Login Not Working in Some Browsers + Solution

If you are tearing your hair out trying to figure out why you are not able to log into the Magento admin on some browsers then this might be your solution. This solution will apply particularly if you are setting up Magento on a brand new server or VPS as you will see. The problem is actually that the server time is wrong. The server time is used for generating cookies and the fact that the time is wrong means that cookies become invalidated immediately. Read On →

Geany Text Editor Remove Hash Comments

I recently needed to quickly remove some commented lines from a .htaccess file using Geany (a really nice lightweight IDE or feature rich text editor depending on your point of view). Geany has some powerful regex replace functionality in there but I found that it was overly aggressive so removed lines that had more than one hash and were in fact title sections that needed to stay intact. The working formula was: Search for: 0 And replace with: \1 And of course tick the regex box.

Setting up database testing in PHPUnit

I have recently been trying to write unit tests for a piece of code that reads and writes to a database. As I have spent far too much time trying to get this to work, this is here to act as an aide-mémoire for the next time that I have to do this. This is the actual class that is used <?php require_once __DIR__ . '/DataPump.php'; /** * These are required to ensure that the PDO object in the class is able to work correctly * @backupGlobals disabled * @backupStaticAttributes disabled */ class DataPumpTest extends PHPUnit_Extensions_Database_TestCase { /** * This is the object that will be tested * @var DataPump */ protected $object; /** * only instantiate pdo once for test clean-up/fixture load * @var PDO */ static private $pdo = null; /** * only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test * @var type */ private $conn = null; /** * Sets up the fixture, for example, opens a network connection. Read On →

5 Useful features of the Opera Browser for Web Developers

1. Remotely debugging mobile websites using your Android phone Dragonfly, Opera’s answer to Firebug and Chrome’s Developer Tools has a killer feature: it’s able to let you use your local desktop to debug a page on another instance of Opera - including Opera Mobile What this means is that all the benefits you get from inspecting elements on your desktop can be done on your Android phone. You can have the full array of debugging: inspecting specific elements, checking the CSS being applied to elements, changing the CSS in real time, and editing the HTML. Read On →