Example #1
0
 /**
  * Lock a certain table in the database.
  *
  * @param string $table the table name
  * @param string $mode the type of locking
  *
  * @return bool of locking
  */
 public function lock($table, $mode = 'write')
 {
     /* connect first */
     if ($this->connect() == self::DB_SUCCESS) {
         /* lock */
         $query = "LOCK TABLES {$table} {$mode}";
         if (Config::getGlobal('debug') >= 0) {
             Debugger::addQuery($query);
         }
         $result = $this->_query($query, true);
         if (!$result) {
             $this->halt("{$mode} lock on {$table} failed.");
         }
         /* return result */
         return $result;
     }
     return 0;
 }
Example #2
0
 /**
  * Executes the statement using the given bind parameters.
  *
  * @param array $params bind parameters
  *
  * @throws StatementException
  */
 protected function _execute($params)
 {
     if (Config::getGlobal('debug') >= 0) {
         Debugger::addQuery($this->_getParsedQuery(), false);
     }
     $this->_bindParams($params);
     if (!$this->m_stmt->execute()) {
         throw new StatementException("Cannot execute statement: {$this->m_stmt->error}", StatementException::STATEMENT_ERROR);
     }
     $this->m_insertId = $this->getDb()->link_id()->insert_id;
     $this->_bindResult();
     if ($this->m_columnNames === null) {
         /** @var MySqliDb $db */
         $db = $this->getDb();
         $db->debugWarnings();
     }
 }