By default this function will append any passed argument to the list of modifiers
to be applied, unless the second argument is set to true.
### Example:
Ignore cache query in MySQL
$query->select(['name', 'city'])->from('products')->modifier('SQL_NO_CACHE');
It will produce the SQL: SELECT SQL_NO_CACHE name, city FROM products
Or with multiple modifiers
$query->select(['name', 'city'])->from('products')->modifier(['HIGH_PRIORITY', 'SQL_NO_CACHE']);
It will produce the SQL: SELECT HIGH_PRIORITY SQL_NO_CACHE name, city FROM products
/** * Modify the limit/offset to TSQL * * @param \Cake\Database\Query $query The query to translate * @return \Cake\Database\Query The modified query */ protected function _selectQueryTranslator($query) { $skip = false; $limit = $query->clause('limit'); $offset = $query->clause('offset'); if (isset($query->clause('select')['count'])) { //TODO instanceof \Cake\Database\Expression\FunctionExpression) $skip = true; } if ($limit && !$offset && !$skip) { $query->modifier(['_auto_top_' => sprintf('FIRST %d', $limit)]); } if ($limit && $offset && !$skip) { $query->modifier(['_auto_top_' => sprintf('FIRST %d SKIP %d', $limit, $offset)]); } if ($skip) { $query->modifier(['_auto_top_' => '']); } return $this->_transformDistinct($query); }
/** * Modify the limit/offset to TSQL * * @param \Cake\Database\Query $query The query to translate * @return \Cake\Database\Query The modified query */ protected function _selectQueryTranslator($query) { $limit = $query->clause('limit'); $offset = $query->clause('offset'); if ($limit && $offset === null) { $query->modifier(['_auto_top_' => sprintf('TOP %d', $limit)]); } if ($offset !== null && !$query->clause('order')) { $query->order($query->newExpr()->add('(SELECT NULL)')); } if ($this->_version() < 11 && $offset !== null) { return $this->_pagingSubquery($query, $limit, $offset); } return $this->_transformDistinct($query); }