Delete all record from table in mysql

17. May 2013

Delete all record from table in mysql

http://stackoverflow.com/questions/8091053/delete-all-record-from-table-in-mysql

TRUNCATE TABLE <table name>;

MySQL, SQL

MySQL transactions examples in PHP

17. May 2013

MySQL transactions examples in PHP

 

 http://stackoverflow.com/questions/2708237/php-mysql-transactions-examples

mysql_query("SET AUTOCOMMIT=0");
mysql_query("START TRANSACTION");
$a1 = mysql_query("INSERT INTO rarara (l_id) VALUES('1')");
$a2 = mysql_query("INSERT INTO rarara (l_id) VALUES('2')");
if ($a1 and $a2)
{ 
mysql_query("COMMIT"); 
} 
else
{
mysql_query("ROLLBACK"); 
}

MySQL, PHP , ,

How to safely increment MySQL integer field?

17. May 2013

How to safely increment MySQL integer field?

http://stackoverflow.com/questions/2033537/php-mysql-how-to-safely-increment-mysql-integer-field

 

UPDATE table SET field = field +1 WHERE [...];

MySQL ,