QueryBuilder
class QueryBuilder
Minimalistic class for building prepared post-FROM SQL query strings
Properties
| private array<string,string> | $data | ||
| private | $fromalias | ||
| private | $joins | ||
| private | $where | ||
| private | $orderby | ||
| private | $orderdesc | ||
| private | $limit | ||
| private | $offset |
Methods
No description
Returns the compiled query as a string
No description
Adds the given value to the internal data array
Base function for safely comparing columns to values
Returns the given string with escaped SQL wildcard characters
Returns a string asserting the given column is null
Returns a string comparing the given column to a value using LIKE
Returns a query string asserting the given column is less than the given value
Returns a query string asserting the given column is greater than the given value
Returns a query string asserting the given column is "true" (greater than zero)
Returns a query string asserting the given column is equal to the given value
Returns a query string asserting the given column is not equal to the given value
Returns a query string that inverts the logic of the given query
Returns a query string that combines the given arguments using OR
Returns a query string that combines the given arguments using AND
Syntactic sugar function to check many OR conditions at once
Syntactic sugar function to check many AND conditions at once
Assigns a WHERE clause to the query
Returns the current WHERE string
Assigns an ORDER BY clause to the query
Assigns a LIMIT clause to the query
Assigns an OFFSET clause to the query (use with LIMIT)
Adds a JOIN clause to the query (can have > 1)
Performs a self join on a table (selects an alias table and sets the WHERE query)
Details
at line 12
array
GetData()
No description
at line 15
string
GetText()
Returns the compiled query as a string
at line 33
string
__toString()
No description
at line 48
protected string
AddData(string $val)
Adds the given value to the internal data array
at line 56
private string
BaseCompare(string $key, $val, string $symbol)
Base function for safely comparing columns to values
at line 62
static string
EscapeWildcards(string $query)
Returns the given string with escaped SQL wildcard characters
at line 68
string
IsNull(string $key)
Returns a string asserting the given column is null
at line 77
string
Like(string $key, string $val, bool $hasMatch = false)
Returns a string comparing the given column to a value using LIKE
at line 85
string
LessThan(string $key, $val)
Returns a query string asserting the given column is less than the given value
at line 88
string
GreaterThan(string $key, $val)
Returns a query string asserting the given column is greater than the given value
at line 91
string
IsTrue(string $key)
Returns a query string asserting the given column is "true" (greater than zero)
at line 94
string
Equals(string $key, $val)
Returns a query string asserting the given column is equal to the given value
at line 101
string
NotEquals(string $key, $val)
Returns a query string asserting the given column is not equal to the given value
at line 108
string
Not(string $arg)
Returns a query string that inverts the logic of the given query
at line 111
string
Or(string ...$args)
Returns a query string that combines the given arguments using OR
at line 114
string
And(string ...$args)
Returns a query string that combines the given arguments using AND
at line 123
string
ManyOr(string $key, array $vals, string $func = 'Equals')
Syntactic sugar function to check many OR conditions at once
at line 135
string
ManyAnd(array $pairs, string $func = 'Equals')
Syntactic sugar function to check many AND conditions at once
at line 143
QueryBuilder
Where(string $where)
Assigns a WHERE clause to the query
at line 146
string|null
GetWhere()
Returns the current WHERE string
at line 149
QueryBuilder
OrderBy(string $orderby, bool|null $desc = null)
Assigns an ORDER BY clause to the query
at line 153
QueryBuilder
Limit(int|null $limit)
Assigns a LIMIT clause to the query
at line 156
QueryBuilder
Offset(int|null $offset)
Assigns an OFFSET clause to the query (use with LIMIT)
at line 169
QueryBuilder
Join(ObjectDatabase $database, string $joinclass, string $joinprop, string $destclass, string $destprop, string|null $destpoly = null, string|null $joinpoly = null)
Adds a JOIN clause to the query (can have > 1)
at line 200
QueryBuilder
SelfJoinWhere(ObjectDatabase $database, string $joinclass, string $prop1, string $prop2, string $tmptable = '_tmptable')
Performs a self join on a table (selects an alias table and sets the WHERE query)
If you need to add extra WHERE to the query, you must add to GetWhere()