Exemplo n.º 1
0
 public function testQueryErrorHandling()
 {
     $this->db->close();
     self::assertEquals(false, $this->db->isReady());
     $this->invokeMethod($this->db, "queryErrorHandling", array("DB server has gone away", "SELECT * FROM " . $this->tableName . " WHERE page_id = 1"));
     self::assertEquals(true, $this->db->isReady());
 }
Exemplo n.º 2
0
 /**
  * Prepare an SQL statement for execution
  *
  * @link  http://php.net/manual/en/mysqli-stmt.prepare.php
  *
  * @param string $query <p>
  *                      The query, as a string. It must consist of a single SQL statement.
  *                      </p>
  *                      <p>
  *                      You can include one or more parameter markers in the SQL statement by
  *                      embedding question mark (?) characters at the
  *                      appropriate positions.
  *                      </p>
  *                      <p>
  *                      You should not add a terminating semicolon or \g
  *                      to the statement.
  *                      </p>
  *                      <p>
  *                      The markers are legal only in certain places in SQL statements.
  *                      For example, they are allowed in the VALUES() list of an INSERT statement
  *                      (to specify column values for a row), or in a comparison with a column in
  *                      a WHERE clause to specify a comparison value.
  *                      </p>
  *                      <p>
  *                      However, they are not allowed for identifiers (such as table or column names),
  *                      in the select list that names the columns to be returned by a SELECT statement),
  *                      or to specify both operands of a binary operator such as the =
  *                      equal sign. The latter restriction is necessary because it would be impossible
  *                      to determine the parameter type. In general, parameters are legal only in Data
  *                      Manipulation Language (DML) statements, and not in Data Definition Language
  *                      (DDL) statements.
  *                      </p>
  *
  * @return bool false on error
  * @since 5.0
  */
 public function prepare($query)
 {
     $this->_sql = $query;
     $this->_sql_with_bound_parameters = $query;
     if (!$this->_db->isReady()) {
         return false;
     }
     if (!$query || $query === '') {
         $this->_debug->displayError('Can\'t prepare an empty Query', false);
         return false;
     }
     $bool = parent::prepare($query);
     if ($bool === false) {
         $this->_debug->displayError('Can\'t prepare Query: ' . $query . ' | ' . $this->error, false);
     }
     return true;
 }