Transaction on cakephp 1.2
Posted on July 31st, 2008 in Programming |
The execute function had been removed from cakephp 1.2 and this left us with use the query function. If you need to use transaction on cakephp 1.2 here is the most simple example.
$this->Model->begin();
$returnQuery = $this->Model->query($query);
if($returnQuery !== false){
$this->Model->commit();
}else{
$this->Model->rollback();
}
$this->Model->begin();
begin will start the transaction
$returnQuery = $this->Model->query($query);
will execute your query (but not and assign the returned value to the returnQuery variable
if($returnQuery !== false){
strict check if return the query returns false
$this->Model->commit();
commit the transaction
$this->Model->rollback();
cancel the transaction












