@param array $where

@throws \Doctrine\ORM\NonUniqueResultException

@return int|mixed
761952
public function count(array $where = [])
    {
        $sql = $this->createQueryBuilder('data');
        $sql->select('COUNT(data)');
        if (\count($where)) {
            foreach ($where as $key => $value) {
                $sql->andWhere('data.' . $key . ' = :' . $key);
                $sql->setParameter($key, $value);
            }
        }

        return $sql->getQuery()->getSingleScalarResult();
    }
927541
public function deleteWhere(array $wheres)
    {
        $query = $this->getSqlObject()
            ->delete()
            ->where($wheres);

        return $this->execute($query);
    }
1371264
function Count($where = null) {
		$this->LoadSchema();
		if ($this->UseCache('count')) {
			$cacheid = md5(json_encode($where));

			if ($value = $this->GetCache('count', $cacheid))
				return $value;
		}

		$this->ResetQuery(array(
			'method' => 'count',
			'table' => $this->table,
			'where' => $where,
		));

		$this->Trigger('access', $where);
		if (!$this->continue)
			return 0;

		$this->Trigger('pull', $where);
		if (!$this->continue)
			return 0;

		$this->Trigger('getall', $where);
		if (!$this->continue)
			return 0;

		$this->db->select('COUNT(*) AS count');
		$this->db->from($this->table);
		if ($where = $this->FilterFields($where, 'where'))
			$this->db->where($where);
		$row = $this->db->get()->row_array();
		if (!$this->continue)
			return 0;

		return isset($cacheid) ? $this->SetCache('count', $cacheid, $row['count']) : $row['count'];
	}
1199238
public static function count($where = null): int
    {
        $select = static::select();

        if ($where !== null) {
            if ($where instanceof Where) {
                $select->field('COUNT(*)', 'total');
                $select->where(clone $where);

            } else if (is_array($where)) {
                $select->field('COUNT(*)', 'total');
                foreach ($where as $field => $value) {
                    $select->where($field, $value);
                }

            } else if (!is_array(static::$primaryKey) && (is_numeric($where) || is_string($where))) {
                $select->field('COUNT(' . static::$primaryKey . ')', 'total');
                $select->where(static::$primaryKey, $where);

            }
        } else {
            $pk = is_string(static::$primaryKey) ? static::$primaryKey : '*';
            $select->field('COUNT(' . $pk . ')', 'total');
        }

        $results = $select->fetchAll();

        if (isset($results[0])) {
            $r = $results[0];
            if (array_key_exists('total', $r)) {
                return (int)$r['total'];
            } else {
                return 0;
            }
        } else {
            return 0;
        }
    }
29326
public function fetchPaginator($where = null)
    {
        if ($where instanceof DbSelect) {
            $adapter = $where;
        } else {
            $select = $this->sql->select();

            if ($where instanceof \Closure) {
                $where($select);
            } elseif ($where !== null) {
                $select->where($where);
            }

            if (count($select->getRawState(Select::GROUP))) {
                $adapter = new DbSelect($select, $this->getAdapter(), $this->getResultSetPrototype());
            } else {
                $count   = null;
                $adapter = new Callback(
                    function ($offset, $itemCountPerPage) use ($select) {
                        $select->offset($offset);
                        $select->limit($itemCountPerPage);

                        $statement = $this->sql->prepareStatementForSqlObject($select);
                        $result    = $statement->execute();

                        $resultSet = $this->getResultSetPrototype() ? clone $this->getResultSetPrototype() : new ResultSet();
                        $resultSet->initialize($result);
                        return $resultSet;
                    }, function () use ($select, &$count) {
                        if ($count === null) {
                            $select = clone $select;
                            $select->columns(array('Gzfextra_Db_Count' => new Expression('count(1)')));
                            $result = $this->sql->prepareStatementForSqlObject($select)->execute()->current();
                            $count  = $result['Gzfextra_Db_Count'];
                        }
                        return $count;
                    }
                );
            }
        }

        return new Paginator($adapter);
    }
10417
public function getCount($where = [], $joinConditions = [], $prefix = 'u')
    {
        return $this->find($where, $prefix, true, $joinConditions);
    }
1087814
public function where($where)
    {
        $where = LambdaUtils::toConditionCallable($where);
        $collection = $this->newInstance();
        foreach($this as $record)
        {
            if(call_user_func($where, $record))
            {
                $collection->add($record);
            }
        }
        return $collection;
    }
201997
public function GetCountWhere($Wheres = '') {
      if (is_array($Wheres))
         $this->SQL->Where($Wheres);
         
      $Data = $this->SQL
         ->Select('MessageID', 'count', 'Count')
         ->From('ConversationMessage')
         ->Get();
         
      if ($Data->NumRows() > 0)
         return $Data->FirstRow()->Count;
      
      return 0;
   }
178019
public function destroyBy(array $where)
    {
        $query = $this->make();

        $query = $this->applyWhere($query, $where);

        return $query->delete();
    }
581121
public function setWhere($where, array $params = array())
    {
        $this->queryBuilder->where($where);
        $this->queryBuilder->setParameters($params);
        return $this;
    }
196375
public static function c($table, $where) {
        $row = DB::qbr($table, array("where" => $where, "cols" => "id"));
        if (!$row) return false;
        return $row["id"];
    }
1032260
public function count($where = null)
  {
    $m = $this->getManager();

    $q = $m->getQueryBuilder()
      ->select($this->getTable())
      ->columns('COUNT(*) as total')
      ->where($where);

    return $m->query($q)->fetchColumn();
  }
301237
public function delete($where)
    {
        $tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
        return $this->_db->delete($tableSpec, $where);
    }
1085897
public static function findCreate(array $where) {
        $item = self::find($where);
        if (!$item) {
            $model = get_called_class();
            /* @var $item Record */
            $item = new $model;
            $item->fromArray($where);
        }
        return $item;
    }
97896
public function findWhere(array $where, $columns = ['*'])
    {
        $this->applyCriteria();
        $this->applyScope();

        $this->applyConditions($where);

        $model = $this->model->get($columns);
        $this->resetModel();

        return $this->parserResult($model);
    }
1024001
public function where($where, &$params)
    {
        if (!is_array($where)) {
            throw new \Exception("Invalid where clause specified, must be an array");
        }

        $params = Helper::toArray($params);

        $query = "";

        $andFlag = false;

        foreach ($where as $field => $value) {

            # Add the and flag if this isn't the first field
            if ($andFlag) {
                $query .= "AND ";
            } else {
                $andFlag = true;
            }

            # Add the field name to the query
            $query .= $this->quoteField($field);

            # Convert arrays to use the in helper
            if (is_array($value)) {
                $helperMap = [
                    "<"     =>  "lessThan",
                    "<="    =>  "lessThanOrEqualTo",
                    ">"     =>  "greaterThan",
                    ">="    =>  "greaterThanOrEqualTo",
                    "="     =>  "equals",
                    "<>"    =>  "notEqualTo",
                ];
                $clause = (string) reset($value);
                if (count($value) === 2 && isset($helperMap[$clause])) {
                    $method = $helperMap[$clause];
                    $val = next($value);
                    trigger_error("Using arrays for complex where clauses is deprecated in favour of the helper methods, eg Sql::" . $method . "(" . $val . ")", E_USER_DEPRECATED);
                    $value = static::$method($val);
                } else {
                    $value = static::in($value);
                }
            }

            # Any parameters not using a helper should use the standard equals helper
            if (!is_object($value)) {
                $value = static::equals($value);
            }

            $query .= " " . $value->getClause() . " ";
            foreach ($value->getValues() as $val) {
                $params[] = $val;
            }
        }

        return $query;
    }
973153
public function where($where)
    {
        if (is_string($where)) {
            $where = [$where];
        }
        
        $this->where = array_merge($this->where, $where);
        
        return $this;
    }