<?php
function begin()
{
mysql_query("BEGIN");
}
function commit()
{
mysql_query("COMMIT");
}
function rollback()
{
mysql_query("ROLLBACK");
}
mysql_connect("localhost","Dude1", "SuperSecret") or die(mysql_error());
mysql_select_db("bedrock") or die(mysql_error());
$query = "INSERT INTO employee (ssn,name,phone) values ('123-45-6789','Matt','1-800-555-1212')";
begin(); // transaction begins
$result = mysql_query($query);
if(!$result)
{
rollback(); // transaction rolls back
echo "transaction rolled back";
exit;
}
else
{
commit(); // transaction is committed
echo "Database transaction was successful";
}
?>
Application development and sharing our knowledge to developer to developer for helping knowledge to build a effective solution for web architect.
Thursday, March 28, 2013
transaction in mysql using php example
Friday, March 22, 2013
what does ReflectionMethod in php
Invokes the reflected method and pass its arguments as array.
<?phpclass getclass{
public function heloname($name) {
return 'Hi' . $name;
}
}
$reflectionMethod = new ReflectionMethod('getclass', 'heloname
');
echo $reflectionMethod->invokeArgs(new
getclass
(), array('Mike'));?>
Subscribe to:
Posts (Atom)