SQL
SQL
Trait providing SQL-related utility methods for database drivers.
trait SQLIncludes query builder initialization, database creation, privilege management, and type/value helpers.
Properties
schemaName
public string $schemaNameType: string
Methods
initQueryBuilder
Initializes the query builder with an optional schema name.
public initQueryBuilder(?string $schemaName): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$schemaName | string | the schema name to use for queries |
getQueryBuilder
Returns a new SQL query builder instance, optionally setting reserved words.
public getQueryBuilder(): QueryBuilderReturns: Hazaar\DBI\Interface\QueryBuilder
createDatabase
Creates a new database with the given name.
public createDatabase(string $name): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | the name of the database to create |
grant
public grant(array|string $privilege, string $to, string $object, ?string $objectType): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$privilege | array | string |
$to | string | |
$object | string | |
$objectType | string | The type of object being granted on (e.g. 'FUNCTION', 'SEQUENCE'). Required for object kinds that Postgres doesn't treat as an implicit relation (tables/views/sequences resolve without a keyword; functions and procedures do not, and will otherwise fail to resolve as if the object were a missing table). |
revoke
public revoke(array|string $privilege, string $from, string $object, ?string $objectType): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$privilege | array | string |
$from | string | |
$object | string | |
$objectType | string | see Hazaar\DBI\DBD\Traits\SQL::grant |
fixValue
Fixes or transforms a value before using it in SQL queries.
protected fixValue(mixed $value): mixedReturns: mixed
Override in implementing classes to provide custom value handling.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | the value to fix or transform |
type
Returns the SQL data type string, optionally with length and array notation.
protected type(?string $dataType, ?int $length): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$dataType | string | the base data type |
$length | int | the length for the data type, if applicable |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000