Esempio n. 1
0
 /**
  * Counts the number of beans of type $type.
  * This method accepts a second argument to modify the count-query.
  * A third argument can be used to provide bindings for the SQL snippet.
  *
  * @param string $type     type of bean we are looking for
  * @param string $addSQL   additional SQL snippet
  * @param array  $bindings parameters to bind to SQL
  *
  * @return integer
  *
  * @throws RedBean_Exception_SQL
  */
 public function count($type, $addSQL = '', $bindings = array())
 {
     try {
         return (int) $this->writer->queryRecordCount($type, array(), $addSQL, $bindings);
     } catch (RedBean_Exception_SQL $exception) {
         if (!$this->writer->sqlStateIn($exception->getSQLState(), array(RedBean_QueryWriter::C_SQLSTATE_NO_SUCH_TABLE))) {
             throw $exception;
         }
     }
     return 0;
 }