Posts Categorized: mySQL

Foreign key restraints

Posted by & filed under Magento, mySQL.

Trying to import a Magento table into a database (drop table if exists) I got an error: The way to get round this is to remove the foreign key constraint CHECK, delete the table, then add the check again:

Handle mysql_query() error without a variable

Posted by & filed under mySQL, PHP.

Thought this was a neat way of testing/handling query errors without assigning the result to a variable because you don’t need a variable unless you are using SELECT. mysql_error() returns empty string if there was no error, which evaluates to false, as pointed out by jakub-arnold in this post

PHP mySQL Database backup

Posted by & filed under mySQL, PHP.

There are times when you need to get an SQL dump of a database but you don’t have access to management tools AND system(), exec() and passthru() commands are disabled. This script from David Walsh will do the trick:

Bitnami