public function lockForUpdate()
    {
        // Pack query then move it to write DB from read DB for transaction
        $sql = $this->_dbr->get_compiled_select();
        $this->_dbr->reset_query();

        return $this->_db->query("{$sql} FOR UPDATE");
    }
public function lockForUpdate()
    {
        // Pack query then move it to write DB from read DB for transaction
        $sql = $this->_dbr->get_compiled_select();
        $this->_dbr->reset_query();

        return $this->_db->query("{$sql} FOR UPDATE");
    }
public function lockForUpdate ( ) { // Pack query then move it to write DB from read DB for transaction $ sql = $ this -> _dbr -> get_compiled_select ( ) ; $ this -> _dbr -> reset_query ( ) ; return $ this -> _db -> query ( "{$sql} FOR UPDATE" ) ; }
Lock the selected rows in the table for updating.

sharedLock locks only for write, lockForUpdate also prevents them from being selected

@example
$this->Model->find()->where('id', 123)
$result = $this->Model->lockForUpdate()->row_array();
@example
// This transaction block will lock selected rows for next same selected
// rows with `FOR UPDATE` lock:
$this->Model->getDB()->trans_start();
$this->Model->find()->where('id', 123)
$result = $this->Model->lockForUpdate()->row_array();
$this->Model->getDB()->trans_complete();

@return object CI_DB_result
Lock the selected rows in the table for updating .