Properties

$idField

$idField : string

The ID field

Type

string

$class

$class : string

The class

Type

string

$parameters

$parameters : array<mixed,string>

The SQL Query Parameters

Type

array<mixed,string>

$usingCache

$usingCache : boolean

Is using cache for results

Type

boolean

$fetchLastStatement

$fetchLastStatement : \Orpheus\SQLRequest\PDOStatement

The current fetch statement

Type

\Orpheus\SQLRequest\PDOStatement

$fetchIsObject

$fetchIsObject : boolean

The current fetch is expecting an object

Type

boolean

Methods

__toString()

__toString() : string

Get object as string

Returns

string

getClone()

getClone(string  $withParameters = true) : \Orpheus\SQLRequest\SQLRequest

Get a clone of current request

Parameters

string $withParameters

True to also copy parameters, default to true

Returns

\Orpheus\SQLRequest\SQLRequest

setIDField()

setIDField(string  $idField) 

Set the ID field

Parameters

string $idField

from()

from(string  $table = null) : mixed|\Orpheus\SQLRequest\SQLRequest

Set/Get the table parameter

Parameters

string $table

Returns

mixed|\Orpheus\SQLRequest\SQLRequest

output()

output(string  $output = null) : mixed|\Orpheus\SQLRequest\SQLRequest

Set/Get the ouput parameter

Parameters

string $output

Returns

mixed|\Orpheus\SQLRequest\SQLRequest

getQuery()

getQuery() : string

Get the query as string

Throws

\Orpheus\SQLRequest\Exception

Returns

string

run()

run() 

Run the query and return results

escapeIdentifier()

escapeIdentifier(string  $identifier) : string

Escape an SQL identifier using SQL Adapter

Parameters

string $identifier

Returns

string

escapeValue()

escapeValue(string  $value) : string

Escape an SQL value using SQL Adapter

Parameters

string $value

Returns

string

select()

select(\Orpheus\SQLAdapter\SQLAdapter  $sqlAdapter = null, string  $idField = 'id', string  $class = null) : \Orpheus\SQLRequest\SQLSelectRequest

Create a select request

Parameters

\Orpheus\SQLAdapter\SQLAdapter $sqlAdapter
string $idField

The ID field

string $class

The class used to instanciate entries

Returns

\Orpheus\SQLRequest\SQLSelectRequest

setUsingCache()

setUsingCache(boolean  $usingCache) : \Orpheus\SQLRequest\SQLSelectRequest

Set the class objects is using cache when getting results

Parameters

boolean $usingCache

Returns

\Orpheus\SQLRequest\SQLSelectRequest

fields()

fields(string|array<mixed,string>  $fields = null) : mixed|\Orpheus\SQLRequest\SQLRequest

Set/Get the field list to get

Parameters

string|array<mixed,string> $fields

Returns

mixed|\Orpheus\SQLRequest\SQLRequest

addField()

addField(string  $field) : \Orpheus\SQLRequest\SQLRequest

Add a field to to the field list

Parameters

string $field

Returns

\Orpheus\SQLRequest\SQLRequest

The current field list must be a string

having()

having(string  $condition = null) : mixed|\Orpheus\SQLRequest\SQLRequest

Set/Get the having condition

Parameters

string $condition

Returns

mixed|\Orpheus\SQLRequest\SQLRequest

where()

where(string  $condition, string  $equality = null, string  $value = null) : \Orpheus\SQLRequest\SQLSelectRequest

Set the whereclause

Parameters

string $condition
string $equality
string $value

Returns

\Orpheus\SQLRequest\SQLSelectRequest

If only $condition is provided, this is used as complete string, e.g where("id = 5") If $equality & $value are provided, it uses it with $condition as a field (identifier), e.g where('id', '=', '5') where identifier and value are escaped with escapeIdentifier() & escapeValue() If $equality is provided but $value is not, $equality is the value and where are using a smart comparator, e.g where('id', '5') All examples return the same results. Smart comparator is IN for array values and = for all other.

orderby()

orderby(string  $fields = null) : mixed|\Orpheus\SQLRequest\SQLSelectRequest

Set/Get the order by filter

Parameters

string $fields

Returns

mixed|\Orpheus\SQLRequest\SQLSelectRequest

groupby()

groupby(string  $field = null) : mixed|\Orpheus\SQLRequest\SQLSelectRequest

Set/Get the group by filter

Parameters

string $field

Returns

mixed|\Orpheus\SQLRequest\SQLSelectRequest

number()

number(integer  $number = null) : mixed|\Orpheus\SQLRequest\SQLSelectRequest

Set/Get the number of expected result (as limit)

Parameters

integer $number

Returns

mixed|\Orpheus\SQLRequest\SQLSelectRequest

maxRows()

maxRows(integer  $number = null) : mixed|\Orpheus\SQLRequest\SQLSelectRequest

Set/Get the number of expected result (as limit)

Parameters

integer $number

Returns

mixed|\Orpheus\SQLRequest\SQLSelectRequest

fromOffset()

fromOffset(integer  $offset = null) : mixed|\Orpheus\SQLRequest\SQLSelectRequest

Set/Get the offset from which we are getting results

Parameters

integer $offset

Returns

mixed|\Orpheus\SQLRequest\SQLSelectRequest

exists()

exists() : boolean

Test if the query has any result

Returns

boolean

count()

count(integer  $max = '') : integer

Count the number of result of this query

Parameters

integer $max

The max number where are expecting

Throws

\Orpheus\SQLRequest\Exception

Returns

integer

fetch()

fetch() : NULL|mixed

Fetch the next result of this query

Returns

NULL|mixed —

Query one time the DBMS and fetch result for next calls This feature is made for common used else it may have an unexpected behavior

__construct()

__construct(\Orpheus\SQLAdapter\SQLAdapter  $sqlAdapter, string  $idField, string  $class = null) 

Constructor

Parameters

\Orpheus\SQLAdapter\SQLAdapter $sqlAdapter
string $idField
string $class

set()

set(string  $parameter, mixed  $value) : \Orpheus\SQLRequest\SQLRequest

Set a parameter for this query

Parameters

string $parameter
mixed $value

Returns

\Orpheus\SQLRequest\SQLRequest

get()

get(string  $parameter, mixed  $default = null) : mixed

Get a parameter for this query

Parameters

string $parameter
mixed $default

Returns

mixed

sget()

sget(string  $parameter, mixed  $value = null) : mixed

Set/Get a parameter for this query

Parameters

string $parameter
mixed $value

Returns

mixed —

If there is a value (non-null), we set it or we get it