Wednesday, October 31, 2012

transaction in mysql php

<?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();

?>

1 comment:

  1. Really like that you are providing such information on PHP MYSQl with JAVASCRIPT ,being enrolled at http://www.wiziq.com/course/5871-php-mysql-with-basic-javascript-integrated-course i really thank you for providing such information it was helpful.

    ReplyDelete

If you Satisfied , Please Leave a comment