Delete all Orders

2 08 2010

Magento version 1.4.1.1
In Database,

SET FOREIGN_KEY_CHECKS = 1;
DELETE FROM sales_flat_order;
DELETE FROM sales_flat_quote;
DELETE FROM eav_entity_store;

Advertisements




Reset Auto-Increment

2 08 2010

Mighty useful for deleting test data!

ALTER TABLE table_name AUTO_INCREMENT = 1;





Escape special characters in SQL statement

1 08 2010

mysql_real_escape_string(string,connection)

$user = mysql_real_escape_string($user);
$pwd = mysql_real_escape_string($pwd);
$sql = "SELECT * FROM users WHERE user='" . $user . "' AND password='" . $pwd . "'"





Select Random Row

29 06 2010

Select id FROM table ORDER BY RAND() LIMIT 1