CRM_Utils_SQL_Select
class CRM_Utils_SQL_Select implements ArrayAccess
Dear God Why Do I Have To Write This (Dumb SQL Builder)
Usage:
Constants
INTERPOLATE_INPUT |
Interpolate values as soon as they are passed in (where(), join(), etc). Default. Pro: Every clause has its own unique namespace for parameters. Con: Probably slower. Advice: Use this when aggregating SQL fragments from agents who maintained by different parties. |
INTERPOLATE_OUTPUT |
Interpolate values when rendering SQL output (toSQL()). Pro: Probably faster. Con: Must maintain an aggregated list of all parameters. Advice: Use this when you have control over the entire query. |
INTERPOLATE_AUTO |
Determine mode automatically. When the first attempt is made to use input-interpolation (eg `where(. .., array(...)) |
Properties
$strict |
Methods
Create a new SELECT query.
Create a partial SELECT query.
Create a new SELECT query.
Make a new copy of this query.
Add a new JOIN clause.
Specify the column(s)/value(s) to return by adding to the SELECT clause
Return only distinct values
Limit results by adding extra condition(s) to the WHERE clause
Group results by adding extra items to the GROUP BY clause.
Limit results by adding extra condition(s) to the HAVING clause
Sort results by adding extra items to the ORDER BY clause.
Set one (or multiple) parameters to interpolate into the query.
Set a limit on the number of records to return.
Insert the results of the SELECT query into another table.
No description
No description
Enable (or disable) strict mode.
Given a string like "field_name = @value", replace "@value" with an escaped SQL string
No description
No description
Has an offset been set.
Get the value of a SQL parameter.
Set the value of a SQL parameter.
Unset the value of a SQL parameter.
Details
at line 141
static CRM_Utils_SQL_Select
from(string $from, array $options = array())
Create a new SELECT query.
at line 151
static CRM_Utils_SQL_Select
fragment(array $options = array())
Create a partial SELECT query.
at line 162
__construct(string $from, array $options = array())
Create a new SELECT query.
at line 172
CRM_Utils_SQL_Select
copy()
Make a new copy of this query.
at line 184
CRM_Utils_SQL_Select
merge(CRM_Utils_SQL_Select $other, array|NULL $parts = NULL)
Merge something or other.
at line 232
CRM_Utils_SQL_Select
join(string|NULL $name, string|array $exprs, array|null $args = NULL)
Add a new JOIN clause.
Note: To add multiple JOINs at once, use $name===NULL and pass an array of $exprs.
at line 252
CRM_Utils_SQL_Select
select(string|array $exprs, null|array $args = NULL)
Specify the column(s)/value(s) to return by adding to the SELECT clause
at line 266
CRM_Utils_SQL_Select
distinct(bool $isDistinct = TRUE)
Return only distinct values
at line 280
CRM_Utils_SQL_Select
where(string|array $exprs, null|array $args = NULL)
Limit results by adding extra condition(s) to the WHERE clause
at line 296
CRM_Utils_SQL_Select
groupBy(string|array $exprs, null|array $args = NULL)
Group results by adding extra items to the GROUP BY clause.
at line 312
CRM_Utils_SQL_Select
having(string|array $exprs, null|array $args = NULL)
Limit results by adding extra condition(s) to the HAVING clause
at line 329
CRM_Utils_SQL_Select
orderBy(string|array $exprs, null|array $args = NULL, int $weight)
Sort results by adding extra items to the ORDER BY clause.
at line 350
CRM_Utils_SQL_Select
param(array|string $keys, null|mixed $value = NULL)
Set one (or multiple) parameters to interpolate into the query.
at line 377
CRM_Utils_SQL_Select
limit(int $limit, int $offset)
Set a limit on the number of records to return.
at line 400
CRM_Utils_SQL_Select
insertInto(string $table, array $fields = array())
Insert the results of the SELECT query into another table.
at line 411
CRM_Utils_SQL_Select
insertIntoField(array $fields)
at line 425
bool
isEmpty(array|NULL $parts = NULL)
at line 459
CRM_Utils_SQL_Select
strict(bool $strict = TRUE)
Enable (or disable) strict mode.
In strict mode, unknown variables will generate exceptions.
at line 480
string
interpolate(string $expr, null|array $args, string $activeMode = self::INTERPOLATE_INPUT)
Given a string like "field_name = @value", replace "@value" with an escaped SQL string
at line 542
string
escapeString(string|NULL $value)
at line 550
string
toSQL()
at line 603
bool
offsetExists(string $offset)
Has an offset been set.
at line 621
mixed
offsetGet(string $offset)
Get the value of a SQL parameter.
at line 642
offsetSet(string $offset, mixed $value)
Set the value of a SQL parameter.
at line 653
offsetUnset(string $offset)
Unset the value of a SQL parameter.