Sqlite
Sqlite
Relational Database Driver - Base Class.
- Full name:
\Hazaar\DBI\DBD\Sqlite
- Parent class:
\Hazaar\DBI\DBD\BaseDriver
Properties
allowConstraints
public bool $allowConstraints
reservedWords
protected string[] $reservedWords
Methods
setTimezone
public setTimezone(string $tz): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$tz | string |
mkdsn
public static mkdsn(\Hazaar\Map $config): string
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$config | \Hazaar\Map |
connect
public connect(string $dsn, ?string $username = null, ?string $password = null, ?array $driverOptions = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$dsn | string | |
$username | ?string | |
$password | ?string | |
$driverOptions | ?array |
quote
public quote(mixed $string, int $type = PDO::PARAM_STR): string
Parameters:
Parameter | Type | Description |
---|---|---|
$string | mixed | |
$type | int |
listTables
public listTables(): array<int,string[]>|false
tableExists
public tableExists(string $table): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$table | string |
describeTable
public describeTable(string $name, ?string $sort = null): array
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | |
$sort | ?string |
prepareValue
public prepareValue(mixed $value, ?string $key = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$value | mixed | |
$key | ?string |
tableName
public tableName(string $name): string
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
Inherited methods
__construct
public __construct(\Hazaar\DBI\Adapter $adapter, ?\Hazaar\Map $config = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$adapter | \Hazaar\DBI\Adapter | |
$config | ?\Hazaar\Map |
__toString
public __toString(): mixed
setTimezone
public setTimezone(string $tz): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$tz | string |
execCount
public execCount(): int
mkdsn
public static mkdsn(\Hazaar\Map $config): false|string
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$config | \Hazaar\Map |
getSchemaName
public getSchemaName(): string
setSchemaName
public setSchemaName(string $schemaName): void
Parameters:
Parameter | Type | Description |
---|---|---|
$schemaName | string |
schemaExists
public schemaExists(string $schemaName): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$schemaName | string |
createSchema
public createSchema(string $schemaName): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$schemaName | string |
connect
public connect(string $dsn, ?string $username = null, ?string $password = null, ?array $driverOptions = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$dsn | string | |
$username | ?string | |
$password | ?string | |
$driverOptions | ?array |
repair
public repair(?string $tableName = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | ?string |
beginTransaction
public beginTransaction(): bool
commit
public commit(): bool
getAttribute
public getAttribute(int $attribute): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$attribute | int |
setAttribute
public setAttribute(int $attribute, mixed $value): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$attribute | int | |
$value | mixed |
inTransaction
public inTransaction(): bool
lastInsertId
public lastInsertId(): false|string
quote
public quote(mixed $string, int $type = PDO::PARAM_STR): false|string
Parameters:
Parameter | Type | Description |
---|---|---|
$string | mixed | |
$type | int |
quoteSpecial
public quoteSpecial(mixed $value): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$value | mixed |
rollBack
public rollBack(): bool
errorCode
public errorCode(): mixed
errorInfo
public errorInfo(): array<int,string>
exec
public exec(string $sql): false|int
Parameters:
Parameter | Type | Description |
---|---|---|
$sql | string |
query
public query(string $sql): false|\PDOStatement
Parameters:
Parameter | Type | Description |
---|---|---|
$sql | string |
prepare
public prepare(string $sql): false|\PDOStatement
Parameters:
Parameter | Type | Description |
---|---|---|
$sql | string |
schemaName
public schemaName(string $tableName): string
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string |
parseSchemaName
public parseSchemaName(string $tableName): array<int,string>
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string |
field
public field(string $string): string
Parameters:
Parameter | Type | Description |
---|---|---|
$string | string |
type
public type(string[] $info): false|string
Parameters:
Parameter | Type | Description |
---|---|---|
$info | string[] |
prepareCriteria
public prepareCriteria(array $criteria, ?string $bindType = null, ?string $tissue = null, ?string $parentRef = null, ?string $optionalKey = null, bool& $setKey = true): string
Parameters:
Parameter | Type | Description |
---|---|---|
$criteria | array | |
$bindType | ?string | |
$tissue | ?string | |
$parentRef | ?string | |
$optionalKey | ?string | |
$setKey | bool |
prepareCriteriaAction
public prepareCriteriaAction(string $action, mixed $value, string $tissue = '=', ?string $key = null, bool& $setKey = true): null|string[]|string
Parameters:
Parameter | Type | Description |
---|---|---|
$action | string | |
$value | mixed | |
$tissue | string | |
$key | ?string | |
$setKey | bool |
prepareFields
public prepareFields(mixed $fields, string[] $exclude = [], string[] $tables = []): string
Parameters:
Parameter | Type | Description |
---|---|---|
$fields | mixed | |
$exclude | string[] | |
$tables | string[] |
prepareValues
public prepareValues(mixed $values): string
Parameters:
Parameter | Type | Description |
---|---|---|
$values | mixed |
prepareValue
public prepareValue(mixed $value, ?string $key = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$value | mixed | |
$key | ?string |
insert
public insert(string $tableName, mixed $fields, null|array|bool|string $returning = null, null|array|string $conflictTarget = null, mixed $conflictUpdate = null, ?\Hazaar\DBI\Table $table = null): false|int|\PDOStatement
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string | |
$fields | mixed | |
$returning | null|array|bool|string | |
$conflictTarget | null|array|string | |
$conflictUpdate | mixed | |
$table | ?\Hazaar\DBI\Table |
update
public update(string $tableName, mixed $fields, array $criteria = [], array $from = [], null|string[]|bool|string $returning = null, array $tables = []): false|int|\PDOStatement
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string | |
$fields | mixed | |
$criteria | array | |
$from | array | |
$returning | null|string[]|bool|string | |
$tables | array |
delete
public delete(string $tableName, mixed $criteria, string[] $from = []): false|int
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string | |
$criteria | mixed | |
$from | string[] |
deleteAll
public deleteAll(string $tableName): false|int
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string |
listTables
public listTables(): array<int,string[]>|false
tableExists
public tableExists(string $tableName): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string |
createTable
public createTable(string $tableName, mixed $columns): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string | |
$columns | mixed |
describeTable
public describeTable(string $tableName, ?string $sort = null): array<int,string[]>|false
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string | |
$sort | ?string |
renameTable
public renameTable(string $fromName, string $toName): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$fromName | string | |
$toName | string |
dropTable
public dropTable(string $name, bool $cascade = false, bool $ifExists = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | |
$cascade | bool | |
$ifExists | bool |
addColumn
public addColumn(string $tableName, mixed $columnSpec): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string | |
$columnSpec | mixed |
alterColumn
public alterColumn(string $tableName, string $column, mixed $columnSpec): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string | |
$column | string | |
$columnSpec | mixed |
dropColumn
public dropColumn(string $tableName, string $column, bool $ifExists = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string | |
$column | string | |
$ifExists | bool |
listSequences
public listSequences(): array<int,string[]>|false
describeSequence
public describeSequence(string $name): array<int,string[]>|false
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
listIndexes
public listIndexes(?string $tableName = null): array|false
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | ?string |
createIndex
public createIndex(string $indexName, string $tableName, mixed $idxInfo): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$indexName | string | |
$tableName | string | |
$idxInfo | mixed |
dropIndex
public dropIndex(string $indexName, bool $ifExists = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$indexName | string | |
$ifExists | bool |
listConstraints
public listConstraints(?string $tableName = null, ?string $type = null, bool $invertType = false): array<int,string[]>|false
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | ?string | |
$type | ?string | |
$invertType | bool |
addConstraint
public addConstraint(string $constraintName, mixed $info): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$constraintName | string | |
$info | mixed |
dropConstraint
public dropConstraint(string $constraintName, string $tableName, bool $cascade = false, bool $ifExists = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$constraintName | string | |
$tableName | string | |
$cascade | bool | |
$ifExists | bool |
listViews
public listViews(): array<int,string[]>|false
describeView
public describeView(string $name): array<int,string[]>|false
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
createView
public createView(string $name, mixed $content): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | |
$content | mixed |
viewExists
public viewExists(string $viewName): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$viewName | string |
dropView
public dropView(string $name, bool $cascade = false, bool $ifExists = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | |
$cascade | bool | |
$ifExists | bool |
listFunctions
List defined functions.
public listFunctions(?string $schemaName = null, bool $includeParameters = false): array<int,array|string>|false
Parameters:
Parameter | Type | Description |
---|---|---|
$schemaName | ?string | |
$includeParameters | bool |
describeFunction
public describeFunction(string $name, ?string $schemaName = null): array<int,string[]>|false
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | |
$schemaName | ?string |
createFunction
Create a new database function.
public createFunction(mixed $name, mixed $spec): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name | mixed | The name of the function to create |
$spec | mixed | A function specification. This is basically the array returned from describeFunction() |
dropFunction
Remove a function from the database.
public dropFunction(string $name, null|string[]|string $argTypes = null, bool $cascade = false, bool $ifExists = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | The name of the function to remove |
$argTypes | null|string[]|string | the argument list of the function to remove |
$cascade | bool | Whether to perform a DROP CASCADE |
$ifExists | bool |
truncate
TRUNCATE empty a table or set of tables.
public truncate(string $tableName, bool $only = false, bool $restartIdentity = false, bool $cascade = false): bool
TRUNCATE quickly removes all rows from a set of tables. It has the same effect as an unqualified DELETE on each table, but since it does not actually scan the tables it is faster. Furthermore, it reclaims disk space immediately, rather than requiring a subsequent VACUUM operation. This is most useful on large tables.
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | string | The name of the table(s) to truncate. Multiple tables are supported. |
$only | bool | Only the named table is truncated. If FALSE, the table and all its descendant tables (if any) are truncated. |
$restartIdentity | bool | Automatically restart sequences owned by columns of the truncated table(s). The default is to no restart. |
$cascade | bool | If TRUE, automatically truncate all tables that have foreign-key references to any of the named tables, or to any tables added to the group due to CASCADE. If FALSE, Refuse to truncate if any of the tables have foreign-key references from tables that are not listed in the command. FALSE is the default. |
listTriggers
List defined triggers.
public listTriggers(?string $tableName = null, string $schemaName = null): array<int,string[]>|false
Parameters:
Parameter | Type | Description |
---|---|---|
$tableName | ?string | |
$schemaName | string | Optional: schema name. If not supplied the current schemaName is used. |
describeTrigger
Describe a database trigger.
public describeTrigger(string $triggerName, string $schemaName = null): array<int,string[]>|false
This will return an array as there can be multiple triggers with the same name but with different attributes
Parameters:
Parameter | Type | Description |
---|---|---|
$triggerName | string | |
$schemaName | string | Optional: schemaName name. If not supplied the current schemaName is used. |
createTrigger
Summary of createTrigger.
public createTrigger(string $triggerName, string $tableName, mixed $spec = []): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$triggerName | string | |
$tableName | string | The table on which the trigger is being created |
$spec | mixed | The spec of the trigger. Basically this is the array returned from describeTriggers() |
dropTrigger
Drop a trigger from a table.
public dropTrigger(string $triggerName, string $tableName, bool $cascade = false, bool $ifExists = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$triggerName | string | |
$tableName | string | The name of the table to remove the trigger from |
$cascade | bool | Whether to drop CASCADE |
$ifExists | bool |
listUsers
public listUsers(): array<int,string[]>|false
listGroups
public listGroups(): array<int,string[]>|false
createRole
public createRole(string $name, ?string $password = null, string[] $privileges = []): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | |
$password | ?string | |
$privileges | string[] |
dropRole
public dropRole(string $name, bool $ifExists = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | |
$ifExists | bool |
listExtensions
public listExtensions(): array<int,string[]>|false
createExtension
public createExtension(string $name): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
dropExtension
public dropExtension(string $name, bool $ifExists = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | |
$ifExists | bool |
createDatabase
public createDatabase(string $name): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
fixValue
Special internal function to fix the default column value.
protected fixValue(mixed $value): mixed
This function is normally overridden by the DBD class being used so that values can be "fixed".
Parameters:
Parameter | Type | Description |
---|---|---|
$value | mixed |
prepareArrayAliases
private prepareArrayAliases(array $array): array
Parameters:
Parameter | Type | Description |
---|---|---|
$array | array |
Automatically generated on 2024-11-14