Execute the given query and return the total number of results.

@param array $query

@return int
499093
public function runCount($query)
	{
		if (isset($this->stored_query_totals[md5(serialize($query))])) {
			return $this->stored_query_totals[md5(serialize($query))];
		}
		
		$query['terms'] = trim($query['terms']);
		if (isset($query['numericFilters'])) {
			$query['numericFilters'] = implode(',', $query['numericFilters']);
		}
		if (isset($query['facets'])) {
			$query['facets'] = implode(',', $query['facets']);
		}
		
		try {
			return array_get($this->getIndex()->search(array_get($query, 'terms'), array_get($query, 'query')), 'nbHits');
		} catch (\Exception $e) {
			return 0;
		}
	}
149770
public function get($resource, array $query = [])
    {
        $exec = $this->execute(Method::$HTTP_GET, $resource, ['query' => $query]);

        return $exec;
    }
878619
public function count($sql)
    {
        $result = $this->execute($sql);
        $res = $result->fetch(PDO::FETCH_ASSOC);
        return $res['total'];
    }
334486
public function query($query, $params = []) {
		$statement = $this->get_statement($query, $params);
		$statement->execute();
	}
105659
public function execute( $query ) {
		if ( $query instanceof QueryBuilder ) {
			$query = $query->getSPARQL();
		}

		if ( !is_string( $query ) ) {
			throw new InvalidArgumentException( '$query has to be a string or an instance of QueryBuilder' );
		}

		$result = $this->getResult( $query );
		
		// TODO also support ask queries (with key 'boolean')
		//      https://www.w3.org/TR/rdf-sparql-json-res/
		return $result['results'];
	}
694091
protected function exec($query)
    {
        try {
            Connect::getConn()->exec($query);
        } catch (Exception $e) {
            static::$response["status"] = "error";
            static::$response["response"] = $e->getMessage();
            static::$response["code"] = $e->getCode();

            return static::terminate(static::$response);
        }
        return null;
    }
1173492
public function affectingStatement($query, $bindings = array())
    {
        $self = $this;

        return $this->run($query, $bindings, function($query, $bindings) use ($self) {
            if ($self->pretending()) return 0;

            // pass query to CodeIgniter database layer
            $bindings = $self->prepareBindings($bindings);
            $self->ci->db->query($query, $bindings);

            // return number of rows affected
            return $self->ci->db->affected_rows();
        });
    }
1084733
public function delete($query, array $data) {
        $stmt = $this->executeQuery($query, $data);
        
        return $stmt->rowCount();       
    }
414870
public function fullUrlWithQuery( array $query )
	{
		return count( $this->query() ) > 0 ? $this->url() . '/?' . http_build_query( array_merge( $this->query(), $query ) ) : $this->fullUrl() . '?' . http_build_query( $query );
	}
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();
    }
189518
public function results(string $query, array $params = [])
    {
        // Prepares the query, then stores it
        $PDOStatement = $this->pdo->prepare($query);

        // Executes the prepared query
        $PDOStatement->execute($params);

        // Fetchs all results, then returns them
        return $PDOStatement->fetchAll();
    }
197689
public function count(array $query = [], string $column = null): int
    {
        return $this->getSelector()->where($query)->count();
    }
1305498
public function update($query, array $data) {
        $stmt = $this->executeQuery($query, $data);

        return $stmt->rowCount();       
    }
323002
public function count(Query $query)
        {
            $query->setTable($this);
            $query->generateCountSQL();

            $resultset = Statement::getPreparedStatement($query)->execute();
            return $resultset->getCount();
        }
1008844
public function exec($query, array $params = [])
    {
        $this->lastStatement = $this->getPDO()->prepare($query);
        $res                 = $this->lastStatement->execute($this->prepareParams($params));
        $errors              = $this->lastStatement->errorInfo();
        return $res;
    }
1172785
public static function query($query)
    {
        //
        static::applySchema();

        //
        $table = self::getTable();
        $whereArray = [];

        //
        if (isset($query['where'])) {
            $whereArray[] = '('.$query['where'].')';
            unset($query['where']);
        }

        //
        foreach ($query as $field => $value) {
            if (in_array($field, ['order', 'limit'])) {
                continue;
            }
            $whereArray[] = "{$field} = '{$value}'";
        }

        //
        $where = count($whereArray) > 0 ? 'WHERE '.implode(' AND ', $whereArray) : '';
        $order = isset($query['order']) ? 'ORDER BY '.$query['order'] : '';
        $limit = isset($query['limit']) ? 'LIMIT '.$query['limit'] : '';
        $sql = "SELECT * FROM {$table} {$where} {$order} {$limit}";
        $results = static::getDatabase()->getResults($sql);

        //
        foreach ($results as &$record) {
            $record = static::create($record);
        }

        return $results;
    }
5277
protected function executeQuery($query)
        {
            $res = @odbc_exec($this->_lnk, $query);
            if(!$res) {
                $error = odbc_errormsg($this->_lnk);
                $this->log('Query failed: '.$error);
                throw new Exception('Executing query failed ' . $error, self::QUERY_FAILED);
            }
            return $res;
        }