Documentation

SQL

Trait that contains various methods for executing SQL queries.

These methods provide functionality for executing SQL queries, fetching results, and performing bulk insert and update operations. The trait encapsulates common SQL operations that can be reused across different classes by using the use keyword to include this trait in a class.

This trait expecting the class to have $db property which is a class that extends \DB\SQL class. If the property doesn't exists, default db will be used.

Table of Contents

Methods

FSQL()  : array<string|int, mixed>
Flat SQL array result. The order of the field is important.
FSQL1()  : string
Single value SQL result.
FSQLC()  : array<string|int, mixed>
Flat SQL array result Column.
FSQLR()  : array<string|int, mixed>
Flat SQL array result Row.
SQL()  : mixed
Execute SQL, if select operation return result in associative array.
SQLBI()  : void
Bulk Insert.
SQLBU()  : void
Bulk Update, only single pk is allowed.
SQLR()  : array<string|int, mixed>
Execute SQL, return first row from result.

Methods

FSQL()

Flat SQL array result. The order of the field is important.

public FSQL() : array<string|int, mixed>
Return values
array<string|int, mixed>

FSQL1()

Single value SQL result.

public FSQL1() : string
Return values
string

value of the query with 1 row, 1 column (e.g. SELECT COUNT(1))

FSQLC()

Flat SQL array result Column.

public FSQLC() : array<string|int, mixed>
Return values
array<string|int, mixed>

FSQLR()

Flat SQL array result Row.

public FSQLR() : array<string|int, mixed>
Return values
array<string|int, mixed>

result that only needed only the first record

SQL()

Execute SQL, if select operation return result in associative array.

public SQL() : mixed
Return values
mixed

result in associative array

SQLBI()

Bulk Insert.

public SQLBI(string $sql, array<string|int, mixed> $values[, int $chunk_size = 100 ]) : void
Parameters
$sql : string
$values : array<string|int, mixed>
$chunk_size : int = 100

(optional)

SQLBU()

Bulk Update, only single pk is allowed.

public SQLBU(string $sql, string $pk, array<string|int, mixed> $values[, int $chunk_size = 100 ]) : void
Parameters
$sql : string
$pk : string
$values : array<string|int, mixed>
$chunk_size : int = 100

(optional)

SQLR()

Execute SQL, return first row from result.

public SQLR() : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results