Use with SELECT COUNT queries to determine if a record exists.

@param          string $statement
@param          mixed  ...$params
@return         bool
@psalm-suppress MixedAssignment
184426
public function exists(string $statement, ...$params): bool
    {
        /**
         * @var string|int|float|bool|null $result
         */
        $result = $this->single($statement, $params);
        return !empty($result);
    }
849256
public function exec($statement, $params) 
    {
        $this->count++;
        try {
            return $this->persistence->exec($statement, $params);
        } catch (\PDOException $e) {
            \common_Logger::w('Failed: '.$statement);
            throw $e;
        }
    }
1365335
public static function record_exists_select($select, array $params = null) {
        global $DB;
        return $DB->record_exists_select(static::TABLE, $select, $params);
    }
186130
public function query($statement) {
		try {
			$stmt = $this->pdo->query($statement);
			return new QueryResult($stmt, $this->pdo);
		} catch (PDOException $e) {
			throw $this->exceptionAdapter->adapt($e, $statement);
		}
	}
422689
public function query($statement, $params = array())
    {
        $returnValue = null;
        $this->preparedExec = false;

       
        if (count($params) > 0){
        	$sth = $this->dbConnector->prepare($statement);
        	$sth->execute($params);
        }
        else{
        	$sth = $this->dbConnector->query($statement);
        }
        
		
        if (!empty($sth)){
        	$returnValue = $sth;
        }

        return $returnValue;
    }
102098
public function prepare(string $statement) : PreparedStatementInterface
    {
        $preparedStatement = @$this->getConnection()->prepare($statement);

        if ($preparedStatement === false) {
            throw new ParserRuntimeException('Statement could not be prepared.', 0);
        }

        return new Sqlite3PreparedStatement($preparedStatement);
    }
1333799
public function query(string $query, array $params = []): bool
	{
		return $this->execute($this->prepare($query, $params));
	}
1040986
public function count($query, array $params = [])
    {
        $stmt = $this->connection->prepare($query);
        $stmt->execute($params);
        return $stmt->fetchColumn();
    }
483457
public function rawExec(string $sql, array $params=[]): bool
  {
    $result = false;

    # Sanity check
    if (empty($sql)) {
      return $result;
    }

    # Obtain transaction, unelss already in a transaction
    $autoCommit = $this->beginTransaction();

    # Prepare
    if ($sth = $this->prepare($sql)) {
      # Binds
      foreach ($params as $bind=>$value) {
        $sth->bindValue( ':'.\ltrim($bind,':'), $value);
      }

      # Execute statement
      if ($sth->execute()) {
        $result = $sth->rowCount() > 0;
      }

      # Close cursor
      $sth->closeCursor();
    }

    # If we had a loacl transaction, commit it
    if ($autoCommit) $this->commit();

    return $result;
  }
496375
private function expandPlaceholders($statement, array $parameters)
    {
        $index = 0;

        return preg_replace_callback(
            '/[\.]{3}\?|\?/',
            function ($match) use (&$index, &$statement, &$parameters) {
                if ($match[0] != '...?') {
                    ++$index;

                    return $match[0];
                }

                if (!is_array($parameters[$index]) || count($parameters[$index]) == 0) {
                    throw new OperationException(
                        sprintf(
                            'Variable length parameter %d is not an array.',
                            $index
                        ),
                        $statement
                    );
                }

                $result = implode(',', array_fill(0, count($parameters[$index]), '?'));

                ++$index;

                return $result;
            },
            $statement
        );
    }
115072
public function count(string $sql, array $params = [])
    {
        $prepared = $this->prepare($sql, $params);
        $this->execute($prepared);
        $result = $prepared['statement']->rowCount();
        $prepared['statement']->closeCursor();
        return $result;
    }
1188793
public function last_affected_rows( Statement $statement = NULL ) {

		if ( $statement && ! $this->last_statement === $statement )
			return FALSE;

		return $this->last_affected_rows;
	}
1099322
public function sqlExists(
		$from,
		$where = null,
		array $params = []
	) {
		$sql = $this->queryBuilder->buildExists($from, $where);
		$query = $this->database->prepare($sql);
		$query->execute($params);
		$this->addQuery($query->queryString, $params);
		return (boolean)$query->fetchColumn();
	}
1059063
public function prepare(string $statement) : PreparedStatementInterface
    {
        try {
            $preparedStatement = $this->getConnection()->prepare($statement);
            return new PdoPreparedStatement($preparedStatement);
        } catch (\PDOException $e) {
            throw new ParserRuntimeException('Statement could not be prepared.', 0, $e);
        }
    }
900874
public function single(string $statement, array $params = [])
    {
        if (!$this->is1DArray($params)) {
            throw new Issues\MustBeOneDimensionalArray(
                'Only one-dimensional arrays are allowed.'
            );
        }
        $stmt = $this->prepare($statement);
        $stmt->execute($params);
        return $stmt->fetchColumn(0);
    }
635431
public function queryAndCount(string $query, array $params = []): int
	{
		$prepared = $this->prepare($query, $params);

		$this->execute($prepared);

		return $prepared['statement']->rowCount();
	}
933807
public function query($statement, $param1 = null, $param2 = null, $param3 = null)
    {
        if ($param3 !== null) {
            return $this->pdo->query($statement, $param1, $param2, $param3);
        }

        if ($param2 !== null) {
            return $this->pdo->query($statement, $param1, $param2);
        }

        if ($param1 !== null) {
            return $this->pdo->query($statement, $param1);
        }

        return $this->pdo->query($statement);
    }