zoukankan      html  css  js  c++  java
  • Can we lock tables while executing a query in ZendDb

    $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();}
  • 相关阅读:
    找“水王”
    用户体验评价
    学习进度12
    个人冲刺10
    学习进度13
    学习进度11
    个人冲刺9
    myeclipse中js报错
    安卓调用三个系统app(打电话,发短息,打开网页)
    关系图绘制详解
  • 原文地址:https://www.cnblogs.com/youlechang123/p/2917055.html
Copyright © 2011-2022 走看看