$db->beginTransaction();try{
$select = $db->select()->forUpdate()// <-- here's the magic->from(
array('a'=>'yourTable'),
array('your','column','names'))->where('someColumn = ?', $whatever );
$result = $this->_adapter->fetchRow( $select );/*
alter data in $result
and update if necessary:
*/
$db->update('yourTable', $result, array('someColumn = ?'=> $whatever ));
$db->commit();}catch(Exception $e ){
$db->rollBack();}
// Start a transaction explicitly.
$db->beginTransaction();try{//Get your data
$sql ="SELECT * FROM page WHERE col='value'";
$result = $db->fetchAll($sql);//Make the insert
$data = array('col1'=>'val1','col2'=>'val2');
$db->insert('page', $data);// If all succeed, commit the transaction and all changes// are committed at once.
$db->commit();}catch(Exception $e){// If any of the queries failed and threw an exception,// we want to roll back the whole transaction, reversing// changes made in the transaction, even those that succeeded.// Thus all changes are committed together, or none are.
$db->rollBack();
echo $e->getMessage();}