+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* @endcode
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
*/
class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery {
private $insertInto = NULL;
private $insertVerb = 'INSERT INTO ';
- private $insertIntoFields = array();
- private $selects = array();
+ private $insertIntoFields = [];
+ private $selects = [];
private $from;
- private $joins = array();
- private $wheres = array();
- private $groupBys = array();
- private $havings = array();
- private $orderBys = array();
+ private $joins = [];
+ private $wheres = [];
+ private $groupBys = [];
+ private $havings = [];
+ private $orderBys = [];
private $limit = NULL;
private $offset = NULL;
private $distinct = NULL;
* @param array $options
* @return CRM_Utils_SQL_Select
*/
- public static function from($from, $options = array()) {
+ public static function from($from, $options = []) {
return new self($from, $options);
}
* @param array $options
* @return CRM_Utils_SQL_Select
*/
- public static function fragment($options = array()) {
+ public static function fragment($options = []) {
return new self(NULL, $options);
}
* Table-name and optional alias.
* @param array $options
*/
- public function __construct($from, $options = array()) {
+ public function __construct($from, $options = []) {
$this->from = $from;
$this->mode = isset($options['mode']) ? $options['mode'] : self::INTERPOLATE_AUTO;
}
throw new RuntimeException("Cannot merge queries that use different interpolation modes ({$this->mode} vs {$other->mode}).");
}
- $arrayFields = array('insertIntoFields', 'selects', 'joins', 'wheres', 'groupBys', 'havings', 'orderBys', 'params');
+ $arrayFields = ['insertIntoFields', 'selects', 'joins', 'wheres', 'groupBys', 'havings', 'orderBys', 'params'];
foreach ($arrayFields as $f) {
if ($parts === NULL || in_array($f, $parts)) {
$this->{$f} = array_merge($this->{$f}, $other->{$f});
}
}
- $flatFields = array('insertInto', 'from', 'limit', 'offset');
+ $flatFields = ['insertInto', 'from', 'limit', 'offset'];
foreach ($flatFields as $f) {
if ($parts === NULL || in_array($f, $parts)) {
if ($other->{$f} !== NULL) {
$exprs = (array) $exprs;
foreach ($exprs as $expr) {
$evaluatedExpr = $this->interpolate($expr, $args);
- $this->orderBys[$evaluatedExpr] = array('value' => $evaluatedExpr, 'weight' => $weight, 'guid' => $guid++);
+ $this->orderBys[$evaluatedExpr] = ['value' => $evaluatedExpr, 'weight' => $weight, 'guid' => $guid++];
}
return $this;
}
* @return CRM_Utils_SQL_Select
* @see insertIntoField
*/
- public function insertInto($table, $fields = array()) {
+ public function insertInto($table, $fields = []) {
$this->insertInto = $table;
$this->insertIntoField($fields);
return $this;
* The fields to fill in the other table (in order).
* @return CRM_Utils_SQL_Select
*/
- public function insertIgnoreInto($table, $fields = array()) {
+ public function insertIgnoreInto($table, $fields = []) {
$this->insertVerb = "INSERT IGNORE INTO ";
return $this->insertInto($table, $fields);
}
* @param array $fields
* The fields to fill in the other table (in order).
*/
- public function replaceInto($table, $fields = array()) {
+ public function replaceInto($table, $fields = []) {
$this->insertVerb = "REPLACE INTO ";
return $this->insertInto($table, $fields);
}
-
/**
* @param array $fields
* The fields to fill in the other table (in order).
*/
public function isEmpty($parts = NULL) {
$empty = TRUE;
- $fields = array(
+ $fields = [
'insertInto',
'insertIntoFields',
'selects',
'orderBys',
'limit',
'offset',
- );
+ ];
if ($parts !== NULL) {
$fields = array_intersect($fields, $parts);
}
}
if ($this->orderBys) {
$orderBys = CRM_Utils_Array::crmArraySortByField($this->orderBys,
- array('weight', 'guid'));
+ ['weight', 'guid']);
$orderBys = CRM_Utils_Array::collect('value', $orderBys);
$sql .= 'ORDER BY ' . implode(', ', $orderBys) . "\n";
}
*/
public function execute($daoName = NULL, $i18nRewrite = TRUE) {
// Don't pass through $params. toSQL() handles interpolation.
- $params = array();
+ $params = [];
// Don't pass through $abort, $trapException. Just use straight-up exceptions.
$abort = TRUE;