class CRM_Utils_SQL_Delete extends CRM_Utils_SQL_BaseParamQuery

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(...))) or output-interpolation (egparam(...)`), the mode will be set. Subsequent calls will be validated using the same mode.

Properties

protected mixed $mode from CRM_Utils_SQL_BaseParamQuery
protected array $params from CRM_Utils_SQL_BaseParamQuery
bool $strict Public to work-around PHP 5.3 limit. from CRM_Utils_SQL_BaseParamQuery

Methods

strict(bool $strict = TRUE)

Enable (or disable) strict mode.

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

string
escapeString(string|NULL $value)

No description

$this
param(array|string $keys, null|mixed $value = NULL)

Set one (or multiple) parameters to interpolate into the query.

bool
offsetExists(string $offset)

Has an offset been set.

mixed
offsetGet(string $offset)

Get the value of a SQL parameter.

offsetSet(string $offset, mixed $value)

Set the value of a SQL parameter.

offsetUnset(string $offset)

Unset the value of a SQL parameter.

from(string $from, array $options = [])

Create a new DELETE query.

__construct(string $from, array $options = [])

Create a new DELETE query.

copy()

Make a new copy of this query.

merge(CRM_Utils_SQL_Delete $other, array|NULL $parts = NULL)

Merge something or other.

where(string|array $exprs, null|array $args = NULL)

Limit results by adding extra condition(s) to the WHERE clause

bool
isEmpty(array|NULL $parts = NULL)

No description

string
toSQL()

No description

execute(string|NULL $daoName = NULL, bool $i18nRewrite = TRUE)

Execute the query.

Details

CRM_Utils_SQL_BaseParamQuery strict(bool $strict = TRUE)

Enable (or disable) strict mode.

In strict mode, unknown variables will generate exceptions.

Parameters

bool $strict

Return Value

CRM_Utils_SQL_BaseParamQuery

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

Parameters

string $expr SQL expression
null|array $args a list of values to insert into the SQL expression; keys are prefix-coded: prefix '@' => escape SQL prefix '#' => literal number, skip escaping but do validation prefix '!' => literal, skip escaping and validation if a value is an array, then it will be imploded

PHP NULL's will be treated as SQL NULL's. The PHP string "null" will be treated as a string.

string $activeMode

Return Value

string

string escapeString(string|NULL $value)

Parameters

string|NULL $value

Return Value

string SQL expression, e.g. "it\'s great" (with-quotes) or NULL (without-quotes)

at line 190
$this param(array|string $keys, null|mixed $value = NULL)

Set one (or multiple) parameters to interpolate into the query.

Parameters

array|string $keys Key name, or an array of key-value pairs.
null|mixed $value The new value of the parameter. Values may be strings, ints, or arrays thereof -- provided that the SQL query uses appropriate prefix (e.g. "@", "!", "#").

Return Value

$this

bool offsetExists(string $offset)

Has an offset been set.

Parameters

string $offset

Return Value

bool

mixed offsetGet(string $offset)

Get the value of a SQL parameter.

Parameters

string $offset

Return Value

mixed

See also

param()
ArrayAccess::offsetGet

offsetSet(string $offset, mixed $value)

Set the value of a SQL parameter.

Parameters

string $offset
mixed $value The new value of the parameter. Values may be strings, ints, or arrays thereof -- provided that the SQL query uses appropriate prefix (e.g. "@", "!", "#").

See also

param()
ArrayAccess::offsetSet

offsetUnset(string $offset)

Unset the value of a SQL parameter.

Parameters

string $offset

See also

param()
ArrayAccess::offsetUnset

at line 95
static CRM_Utils_SQL_Delete from(string $from, array $options = [])

Create a new DELETE query.

Parameters

string $from Table-name and optional alias.
array $options

Return Value

CRM_Utils_SQL_Delete

at line 106
__construct(string $from, array $options = [])

Create a new DELETE query.

Parameters

string $from Table-name and optional alias.
array $options

at line 116
CRM_Utils_SQL_Delete copy()

Make a new copy of this query.

Return Value

CRM_Utils_SQL_Delete

at line 128
CRM_Utils_SQL_Delete merge(CRM_Utils_SQL_Delete $other, array|NULL $parts = NULL)

Merge something or other.

Parameters

CRM_Utils_SQL_Delete $other
array|NULL $parts ex: 'wheres'

Return Value

CRM_Utils_SQL_Delete

at line 170
CRM_Utils_SQL_Delete where(string|array $exprs, null|array $args = NULL)

Limit results by adding extra condition(s) to the WHERE clause

Parameters

string|array $exprs list of SQL expressions
null|array $args use NULL to disable interpolation; use an array of variables to enable

Return Value

CRM_Utils_SQL_Delete

at line 201
bool isEmpty(array|NULL $parts = NULL)

Parameters

array|NULL $parts List of fields to check (e.g. 'wheres'). Defaults to all.

Return Value

bool

at line 222
string toSQL()

Return Value

string SQL statement

at line 253
CRM_Core_DAO execute(string|NULL $daoName = NULL, bool $i18nRewrite = TRUE)

Execute the query.

To examine the results, use a function like fetch(), fetchAll(), fetchValue(), or fetchMap().

Parameters

string|NULL $daoName The return object should be an instance of this class. Ex: 'CRM_Contact_BAO_Contact'.
bool $i18nRewrite If the system has multilingual features, should the field/table names be rewritten?

Return Value

CRM_Core_DAO

See also

CRM_Core_DAO::executeQuery
CRM_Core_I18n_Schema::rewriteQuery