wpdb::suppress_errors PHP Method

suppress_errors() public method

By default database errors are suppressed, with a simple call to this function they can be enabled.
See also: wpdb::hide_errors()
Since: 2.5.0
public suppress_errors ( boolean $suppress = true ) : boolean
$suppress boolean Optional. New value. Defaults to true.
return boolean Old value
    public function suppress_errors($suppress = true)
    {
        $errors = $this->suppress_errors;
        $this->suppress_errors = (bool) $suppress;
        return $errors;
    }

Usage Example

コード例 #1
0
ファイル: Wpdb.php プロジェクト: gedex/wp-codeception
 /**
  * Fetches rows from database.
  *
  * @since 1.0.0
  *
  * @access public
  * @param string $table The table name.
  * @param array|string $columns The array of columns to select.
  * @param array $criteria The array of conditions.
  * @return array The array of fetched rows.
  */
 public function grabFromDatabase($table, $columns, $criteria = array())
 {
     $query = $this->_prepareQuery($table, $columns, $criteria);
     $this->debugSection('Query', $query);
     $suppress_errors = $this->_wpdb->suppress_errors(true);
     $results = $this->_wpdb->get_results($query);
     $this->_wpdb->suppress_errors($suppress_errors);
     if (!empty($this->_wpdb->last_error)) {
         $this->fail('Database error: ' . $this->_wpdb->last_error);
         return;
     }
     return $results;
 }