src/Database.php
public function run($sql, array $params = [], bool $returnStatement = false, int $fetchMode = PDO::FETCH_ASSOC)
    {
        if ($sql instanceof Query) {
            $params = $sql->getParams();
            $sql = $sql->getSql();
        }

        $stm = $this->prepare($sql);
        $stm->execute($params);
        $this->logQuery($sql, $params);

        if ($returnStatement) {
            return $stm;
        } elseif (substr(trim($sql), 0, 6) === 'SELECT') {
            return $stm->fetchAll($fetchMode);
        } else {
            return $stm->rowCount();
        }
    }
public function run($sql, array $params = [], bool $returnStatement = false, int $fetchMode = PDO::FETCH_ASSOC)
    {
        if ($sql instanceof Query) {
            $params = $sql->getParams();
            $sql = $sql->getSql();
        }

        $stm = $this->prepare($sql);
        $stm->execute($params);
        $this->logQuery($sql, $params);

        if ($returnStatement) {
            return $stm;
        } elseif (substr(trim($sql), 0, 6) === 'SELECT') {
            return $stm->fetchAll($fetchMode);
        } else {
            return $stm->rowCount();
        }
    }
Run a query using a prepared statement and return an appropriate value.

The return value is an array of rows for SELECT statements and a number of affected rows
for any other type of statement.

@param string|Query $sql
@param array $params
@param boolean $returnStatement
@param int $fetchMode
@return array|int|PDOStatement