Documentation

Builder
in package

The main Query Builder class. Objects initialized from this class are responsible for building queries and handling the libraries that are used to execute those queries

Tags
author

Jason Napolitano

version
1.0.0
since
1.0.0
license

MIT https://mit-license.org

Table of Contents

$config  : string
$connection  : PDO
PDO Connection
$modules  : array<string|int, mixed>
Module collection
$query  : string|null
Raw SQL Query
$table  : string
__call()  : $this
Check to see if the module used for a query exists within the $modules array, extends the correct class, and implements the correct interface.
__construct()  : mixed
Constructor
__destruct()  : mixed
Destructor
__toString()  : string
__toString() implementation
close()  : void
Close the PDO connection
execute()  : PDOStatement
Execute a query and return a PDOStatement
toArray()  : array<string|int, mixed>
Wrapper for $this->get()
toJSON()  : string|false
Return the results as a JSON string
toSQL()  : string
Returns the trimmed string value of $query
get()  : array<string|int, mixed>|null
Return the results as an array
prepare()  : PDOStatement|false
Generates a prepared PDO statement using a trimmed query string
query()  : PDOStatement|false
Generates a PDO query

Properties

$config read-only

private string $config

$connection

PDO Connection

private PDO $connection

$modules

Module collection

private array<string|int, mixed> $modules = ['whereNot' => null, 'groupBy' => null, 'orderBy' => null, 'andLike' => null, 'notLike' => null, 'update' => null, 'delete' => null, 'insert' => null, 'offset' => null, 'select' => null, 'orLike' => null, 'count' => null, 'where' => null, 'limit' => null, 'join' => null, 'like' => null, 'and' => null, 'or' => null]
Tags
see
BaseConfig::$modules

$query

Raw SQL Query

private string|null $query = ''

$table read-only

private string $table

Methods

__call()

Check to see if the module used for a query exists within the $modules array, extends the correct class, and implements the correct interface.

public __call([string|null $module = null ][, mixed $arguments = null ]) : $this

Once verified we call the query module from within our config clas,s and execute the query that corresponds to that library

Parameters
$module : string|null = null

The module within $modules

$arguments : mixed = null

The arguments to pass to the query

Tags
throws
ReflectionException
Return values
$this

__construct()

Constructor

public __construct(string $table, string $config) : mixed
Parameters
$table : string

Database table

$config : string

Config class

Return values
mixed

__toString()

__toString() implementation

public __toString() : string
Tags
see
Builder::toSQL()
Return values
string

close()

Close the PDO connection

public close() : void
Return values
void

execute()

Execute a query and return a PDOStatement

public execute([array<string|int, mixed>|null $params = null ]) : PDOStatement
Parameters
$params : array<string|int, mixed>|null = null

An array of params to bind to the query [optional]

Return values
PDOStatement

toArray()

Wrapper for $this->get()

public toArray() : array<string|int, mixed>
Tags
see
Builder::get()
Return values
array<string|int, mixed>

toJSON()

Return the results as a JSON string

public toJSON() : string|false
Tags
see
Builder::get()
Return values
string|false

toSQL()

Returns the trimmed string value of $query

public toSQL() : string
Tags
see
Builder::$query
Return values
string

get()

Return the results as an array

private get() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

prepare()

Generates a prepared PDO statement using a trimmed query string

private prepare(string $query) : PDOStatement|false
Parameters
$query : string
Return values
PDOStatement|false

query()

Generates a PDO query

private query(string $query) : PDOStatement|false
Parameters
$query : string
Return values
PDOStatement|false

Search results