Airship\Engine\Database::safeQuery PHP Méthode

safeQuery() public méthode

Perform a Parameterized Query
public safeQuery ( string $statement, array $params = [], integer $fetch_style = PDO::FETCH_ASSOC ) : mixed
$statement string
$params array
$fetch_style integer
Résultat mixed -- array if SELECT
    public function safeQuery(string $statement, array $params = [], int $fetch_style = \PDO::FETCH_ASSOC)
    {
        if (empty($params)) {
            $stmt = $this->pdo->query($statement);
            if ($stmt !== false) {
                return $stmt->fetchAll($fetch_style);
            }
            return false;
        }
        $stmt = $this->pdo->prepare($statement);
        if ($stmt === false) {
            throw new DBAlert\QueryError($this->errorInfo()[2] ?? \json_encode([$statement, $params]), (int) $this->errorInfo()[1]);
        }
        $stmt->execute($params);
        return $stmt->fetchAll($fetch_style);
    }