<?php
MYISAM Not Support Transaction
/*
CREATE TABLE IF NOT EXISTS `table1` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(250) NOT NULL,
`address` varchar(250) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
*/
$host = 'localhost';
$user = 'rajeev';
$password = 'mypass';
$db = 'demo';
$con = mysql_connect($host, $user, $password);
mysql_select_db( $db);
mysql_query("SET AUTOCOMMIT=0");
mysql_query("START TRANSACTION");
$query = "INSERT INTO table1 (name,address) values ('name','bhopal')";
$result = mysql_query($query);
if($result){
mysql_query("COMMIT");
} else {
mysql_query("ROLLBACK");
}
mysql_close();
?>
Comments
Post a Comment
If you Satisfied , Please Leave a comment