/** * @param IQuarkModel $model * @param $criteria * @param $limit * @param $skip * @param $options * * @return int */ public function Count(IQuarkModel $model, $criteria, $limit, $skip, $options = []) { $result = $this->_sql->Count($model, $criteria, $options + array(QuarkModel::OPTION_FIELDS => array(QuarkSQL::FIELD_COUNT_ALL), QuarkModel::OPTION_SKIP => $skip, QuarkModel::OPTION_LIMIT => $limit == 0 ? 'ALL' : $limit)); if (!$result) { return 0; } $out = pg_fetch_assoc($result); return isset($out['count']) ? (int) $out['count'] : 0; }
/** * @param IQuarkModel $model * @param $criteria * @param $limit * @param $skip * @param $options * * @return int */ public function Count(IQuarkModel $model, $criteria, $limit, $skip, $options = []) { $result = $this->_sql->Count($model, $criteria, $options + array(QuarkModel::OPTION_FIELDS => array(QuarkSQL::FIELD_COUNT_ALL), QuarkModel::OPTION_SKIP => $skip, QuarkModel::OPTION_LIMIT => $limit)); return !$result ? 0 : (int) $result->fetch_row()[0]; }