Documentation

QueryBuilder
in package
implements IQueryBuilder

Class for generating queries for the MySql driver.

This class implements the IQueryBuilder interface, providing methods to generate various types of SQL queries compatible with the MySql database.

Table of Contents

Interfaces

IQueryBuilder
Interface for building SQL queries.

Methods

CreateBatchInsert()  : string
Creates a batch INSERT query.
CreateBegin()  : string
Creates a BEGIN transaction query.
CreateCommit()  : string
Creates a COMMIT transaction query.
CreateDelete()  : string
Creates a DELETE query.
CreateInsert()  : string
Creates an INSERT query.
CreateInsertOrUpdate()  : string
Creates an INSERT INTO ... ON DUPLICATE KEY UPDATE query.
CreateReplace()  : string
Creates a REPLACE INTO query.
CreateRollback()  : string
Creates a ROLLBACK transaction query.
CreateShowField()  : string
Creates a SHOW COLUMNS FROM query for a specific table.
CreateShowTables()  : string
Creates a SHOW TABLES query.
CreateUpdate()  : string
Creates an UPDATE query.

Methods

CreateBatchInsert()

Creates a batch INSERT query.

public CreateBatchInsert(string $table, array<string|int, mixed>|object $data) : string
Parameters
$table : string

The name of the table.

$data : array<string|int, mixed>|object

The data to insert in batch.

Return values
string

The generated batch INSERT query.

CreateBegin()

Creates a BEGIN transaction query.

public CreateBegin([string|null $type = null ]) : string
Parameters
$type : string|null = null

(optional) The type of transaction (e.g., 'readonly', 'readwrite'). Default is null.

Return values
string

The generated BEGIN transaction query.

CreateCommit()

Creates a COMMIT transaction query.

public CreateCommit() : string
Return values
string

The generated COMMIT transaction query.

CreateDelete()

Creates a DELETE query.

public CreateDelete(string $table, string $condition) : string
Parameters
$table : string

The name of the table.

$condition : string

The condition for deleting the records.

Return values
string

The generated DELETE query.

CreateInsert()

Creates an INSERT query.

public CreateInsert(string $table, array<string|int, mixed>|object $data[, string $returning = '' ]) : string
Parameters
$table : string

The name of the table.

$data : array<string|int, mixed>|object

The data to insert.

$returning : string = ''

(optional) The returning clause for the query. Default is empty string.

Return values
string

The generated INSERT query.

CreateInsertOrUpdate()

Creates an INSERT INTO ... ON DUPLICATE KEY UPDATE query.

public CreateInsertOrUpdate(string $table, array<string|int, mixed>|object $data[, array<string|int, mixed> $exceptFields = array() ][, string $returning = '' ]) : string
Parameters
$table : string

The name of the table.

$data : array<string|int, mixed>|object

The data to insert or update.

$exceptFields : array<string|int, mixed> = array()

(optional) The fields to exclude from the update statement. Default is an empty array.

$returning : string = ''

(optional) The returning clause for the query. Default is empty string.

Return values
string

The generated INSERT INTO ... ON DUPLICATE KEY UPDATE query.

CreateReplace()

Creates a REPLACE INTO query.

public CreateReplace(string $table, array<string|int, mixed>|object $data[, string $returning = '' ]) : string
Parameters
$table : string

The name of the table.

$data : array<string|int, mixed>|object

The data to replace.

$returning : string = ''

(optional) The returning clause for the query. Default is empty string.

Return values
string

The generated REPLACE INTO query.

CreateRollback()

Creates a ROLLBACK transaction query.

public CreateRollback() : string
Return values
string

The generated ROLLBACK transaction query.

CreateShowField()

Creates a SHOW COLUMNS FROM query for a specific table.

public CreateShowField(string $table) : string
Parameters
$table : string

The name of the table.

Return values
string

The generated SHOW COLUMNS FROM query.

CreateShowTables()

Creates a SHOW TABLES query.

public CreateShowTables() : string
Return values
string

The generated SHOW TABLES query.

CreateUpdate()

Creates an UPDATE query.

public CreateUpdate(string $table, string $condition, array<string|int, mixed>|object $data) : string
Parameters
$table : string

The name of the table.

$condition : string

The condition for updating the records.

$data : array<string|int, mixed>|object

The data to update.

Return values
string

The generated UPDATE query.


        
On this page

Search results