X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FSQL%2FSelect.php;h=bdb892ed4d9e13f2adbac689cdfc61a1bf63a28d;hb=c6dd2cccea85ec30969bdf444e55c3cdf22ec54f;hp=6377d4134fbd49a9342678ea032031f47a3f32cc;hpb=c3ba729df769eade45a1ea8a0cfd08f9599c43f2;p=civicrm-core.git diff --git a/CRM/Utils/SQL/Select.php b/CRM/Utils/SQL/Select.php index 6377d4134f..bdb892ed4d 100644 --- a/CRM/Utils/SQL/Select.php +++ b/CRM/Utils/SQL/Select.php @@ -84,14 +84,14 @@ 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; @@ -104,7 +104,7 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { * @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); } @@ -114,7 +114,7 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { * @param array $options * @return CRM_Utils_SQL_Select */ - public static function fragment($options = array()) { + public static function fragment($options = []) { return new self(NULL, $options); } @@ -125,7 +125,7 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { * 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; } @@ -170,14 +170,14 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { 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) { @@ -304,7 +304,7 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { $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; } @@ -356,7 +356,7 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { * @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; @@ -371,7 +371,7 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { * 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); } @@ -384,12 +384,11 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { * @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). @@ -411,7 +410,7 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { */ public function isEmpty($parts = NULL) { $empty = TRUE; - $fields = array( + $fields = [ 'insertInto', 'insertIntoFields', 'selects', @@ -423,7 +422,7 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { 'orderBys', 'limit', 'offset', - ); + ]; if ($parts !== NULL) { $fields = array_intersect($fields, $parts); } @@ -470,7 +469,7 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { } 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"; } @@ -504,7 +503,7 @@ class CRM_Utils_SQL_Select extends CRM_Utils_SQL_BaseParamQuery { */ 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;