public function count($type, $addSQL = '', $bindings = array())
{
$type = AQueryWriter::camelsSnake($type);
if (count(explode('_', $type)) > 2) {
throw new RedException('Invalid type for count.');
}
try {
return (int) $this->writer->queryRecordCount($type, array(), $addSQL, $bindings);
} catch (SQLException $exception) {
if (!$this->writer->sqlStateIn($exception->getSQLState(), array(QueryWriter::C_SQLSTATE_NO_SUCH_TABLE, QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN))) {
throw $exception;
}
}
return 0;
}