The Pdo\Sqlite class

(PHP 8 >= 8.4.0)

Introduction

A PDO subclass representing a connection using the SQLite PDO driver.

This driver supports a dedicated SQL query parser for the SQLite dialect. It can handle the following:

  • Single, double-quoted, and backtick literals, with doubling as escaping mechanism.

  • Square brackets quoting for identifiers.

  • Two-dashes and C-style comments (non-nested).

Class synopsis

class Pdo\Sqlite extends PDO {
/* Inherited constants */
public const int PDO::PARAM_NULL;
public const int PDO::PARAM_BOOL = 5;
public const int PDO::PARAM_INT = 1;
public const int PDO::PARAM_STR = 2;
public const int PDO::PARAM_LOB = 3;
public const int PDO::PARAM_STMT = 4;
public const int PDO::PARAM_STR_NATL;
public const int PDO::PARAM_STR_CHAR;
public const int PDO::PARAM_EVT_FREE;
public const int PDO::FETCH_DEFAULT;
public const int PDO::FETCH_LAZY;
public const int PDO::FETCH_ASSOC;
public const int PDO::FETCH_NUM;
public const int PDO::FETCH_BOTH;
public const int PDO::FETCH_OBJ;
public const int PDO::FETCH_BOUND;
public const int PDO::FETCH_COLUMN;
public const int PDO::FETCH_CLASS;
public const int PDO::FETCH_INTO;
public const int PDO::FETCH_FUNC;
public const int PDO::FETCH_GROUP;
public const int PDO::FETCH_UNIQUE;
public const int PDO::FETCH_KEY_PAIR;
public const int PDO::FETCH_NAMED;
public const int PDO::ATTR_PREFETCH;
public const int PDO::ATTR_TIMEOUT;
public const int PDO::ATTR_ERRMODE;
public const int PDO::ATTR_CASE;
public const int PDO::ATTR_CURSOR;
public const int PDO::ERRMODE_SILENT;
public const int PDO::CASE_NATURAL;
public const int PDO::CASE_LOWER;
public const int PDO::CASE_UPPER;
public const int PDO::NULL_NATURAL;
public const int PDO::NULL_TO_STRING;
public const string PDO::ERR_NONE;
public const int PDO::FETCH_ORI_NEXT;
public const int PDO::FETCH_ORI_LAST;
public const int PDO::FETCH_ORI_ABS;
public const int PDO::FETCH_ORI_REL;
public const int PDO::CURSOR_FWDONLY;
public const int PDO::CURSOR_SCROLL;
/* Constants */
public const int DETERMINISTIC;
public const int OPEN_READONLY;
public const int OPEN_READWRITE;
public const int OPEN_CREATE;
public const int ATTR_OPEN_FLAGS;
public const int ATTR_BUSY_STATEMENT;
public const int OK;
public const int DENY;
public const int IGNORE;
/* Methods */
public function createAggregate(
    string $name,
    callable $step,
    callable $finalize,
    int $numArgs = -1
): bool
public function createCollation(string $name, callable $callback): bool
public function createFunction(
    string $function_name,
    callable $callback,
    int $num_args = -1,
    int $flags = 0
): bool
public function loadExtension(string $name): void
public function openBlob(
    string $table,
    string $column,
    int $rowid,
    ?string $dbname = "main",
    int $flags = Pdo\Sqlite::OPEN_READONLY
): resource|false
public function setAuthorizer(?callable $callback): void
/* Inherited methods */
public function PDO::__construct(
    string $dsn,
    ?string $username = null,
    #[\SensitiveParameter]?string $password = null,
    ?array $options = null
)
public function PDO::beginTransaction(): bool
public function PDO::commit(): bool
public static function PDO::connect(
    string $dsn,
    ?string $username = null,
    #[\SensitiveParameter]?string $password = null,
    ?array $options = null
): static
public function PDO::errorCode(): ?string
public function PDO::errorInfo(): array
public function PDO::exec(string $statement): int|false
public function PDO::getAttribute(int $attribute): mixed
public static function PDO::getAvailableDrivers(): array
public function PDO::inTransaction(): bool
public function PDO::lastInsertId(?string $name = null): string|false
public function PDO::prepare(string $query, array $options = []): PDOStatement|false
public function PDO::query(string $query, ?int $fetchMode = null): PDOStatement|false
public function PDO::query(string $query, ?int $fetchMode = PDO::FETCH_COLUMN, int $colno): PDOStatement|false
public function PDO::query(
    string $query,
    ?int $fetchMode = PDO::FETCH_CLASS,
    string $classname,
    array $constructorArgs
): PDOStatement|false
public function PDO::query(string $query, ?int $fetchMode = PDO::FETCH_INTO, object $object): PDOStatement|false
public function PDO::quote(string $string, int $type = PDO::PARAM_STR): string|false
public function PDO::rollBack(): bool
public function PDO::setAttribute(int $attribute, mixed $value): bool
}

Predefined Constants

Pdo\Sqlite::DETERMINISTIC

Pdo\Sqlite::OPEN_READONLY

Pdo\Sqlite::OPEN_READWRITE

Pdo\Sqlite::OPEN_CREATE

Pdo\Sqlite::ATTR_OPEN_FLAGS

Pdo\Sqlite::ATTR_READONLY_STATEMENT

Pdo\Sqlite::ATTR_EXTENDED_RESULT_CODES

Pdo\Sqlite::ATTR_BUSY_STATEMENT

A read-only statement attribute, retrieved with PDOStatement::getAttribute(), which is true if the statement has been executed and still has a pending row, and false otherwise. Available as of PHP 8.5.0.

Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT

A statement attribute controlling the explain mode, set with PDOStatement::setAttribute(). Possible values are Pdo\Sqlite::EXPLAIN_MODE_PREPARED, Pdo\Sqlite::EXPLAIN_MODE_EXPLAIN, and Pdo\Sqlite::EXPLAIN_MODE_EXPLAIN_QUERY_PLAN. A ValueError is thrown if PHP has been compiled against a libsqlite older than 3.43.0. Available as of PHP 8.5.0.

Pdo\Sqlite::EXPLAIN_MODE_PREPARED

Value for Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT: returns the statement as prepared (no explanation). Available as of PHP 8.5.0, when compiled against libsqlite >= 3.43.0.

Pdo\Sqlite::EXPLAIN_MODE_EXPLAIN

Value for Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT: returns the opcodes of the virtual machine used to execute the statement (equivalent to SQLite's EXPLAIN). Available as of PHP 8.5.0, when compiled against libsqlite >= 3.43.0.

Pdo\Sqlite::EXPLAIN_MODE_EXPLAIN_QUERY_PLAN

Value for Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT: returns the query plan (equivalent to SQLite's EXPLAIN QUERY PLAN). Available as of PHP 8.5.0, when compiled against libsqlite >= 3.43.0.

Pdo\Sqlite::ATTR_TRANSACTION_MODE

A connection attribute configuring the transaction mode used by PDO::beginTransaction(). Possible values are Pdo\Sqlite::TRANSACTION_MODE_DEFERRED, Pdo\Sqlite::TRANSACTION_MODE_IMMEDIATE, and Pdo\Sqlite::TRANSACTION_MODE_EXCLUSIVE. Available as of PHP 8.5.0.

Pdo\Sqlite::TRANSACTION_MODE_DEFERRED

Value for Pdo\Sqlite::ATTR_TRANSACTION_MODE: uses SQLite's DEFERRED transaction mode (the default). Available as of PHP 8.5.0.

Pdo\Sqlite::TRANSACTION_MODE_IMMEDIATE

Value for Pdo\Sqlite::ATTR_TRANSACTION_MODE: uses SQLite's IMMEDIATE transaction mode. Available as of PHP 8.5.0.

Pdo\Sqlite::TRANSACTION_MODE_EXCLUSIVE

Value for Pdo\Sqlite::ATTR_TRANSACTION_MODE: uses SQLite's EXCLUSIVE transaction mode. Available as of PHP 8.5.0.

Pdo\Sqlite::OK

Return value of an authorizer callback set with Pdo\Sqlite::setAuthorizer(), allowing the action. Available as of PHP 8.5.0.

Pdo\Sqlite::DENY

Return value of an authorizer callback set with Pdo\Sqlite::setAuthorizer(), denying the action. Available as of PHP 8.5.0.

Pdo\Sqlite::IGNORE

Return value of an authorizer callback set with Pdo\Sqlite::setAuthorizer(), substituting a null value for the column that would have been read. Available as of PHP 8.5.0.

Table of Contents

add a note

User Contributed Notes

There are no user contributed notes for this page.