Psecio\Gatekeeper\DataSource\Mysql::count PHP Метод

count() публичный Метод

All where conditions applied with AND
public count ( Modler\Model $model, array $where = [] ) : array
$model Modler\Model Model instance
$where array Data to use in "where" statement
Результат array Fetched data
    public function count(\Modler\Model $model, array $where = array())
    {
        $properties = $model->getProperties();
        list($columns, $bind) = $this->setup($where);
        $update = array();
        foreach ($bind as $column => $name) {
            // See if we keep to transfer it over to a column name
            if (array_key_exists($column, $properties)) {
                $column = $properties[$column]['column'];
            }
            $update[] = $column . ' = ' . $name;
        }
        $sql = 'select count(*) as `count` from ' . $model->getTableName();
        if (!empty($update)) {
            $sql .= ' where ' . implode(' and ', $update);
        }
        $result = $this->fetch($sql, $where, true);
        return $result;
    }