octicon-rss(16/)
You've already forked yii2
mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-10 23:50:38 +08:00
Parameter "options" added to "yii\sphinx\Command::update()"
This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
octicon-diff(16/tw-mr-1) 4 changed files with 44 additions and 5 deletions
@@ -453,11 +453,12 @@ class Command extends Component
|
||||
* @param string|array $condition the condition that will be put in the WHERE part. Please
|
||||
* refer to [[Query::where()]] on how to specify condition.
|
||||
* @param array $params the parameters to be bound to the command
|
||||
* @param array $options list of options in format: optionName => optionValue
|
||||
* @return static the command object itself
|
||||
*/
|
||||
public function update($index, $columns, $condition = '', $params = [])
|
||||
public function update($index, $columns, $condition = '', $params = [], $options = [])
|
||||
{
|
||||
$sql = $this->db->getQueryBuilder()->update($index, $columns, $condition, $params);
|
||||
$sql = $this->db->getQueryBuilder()->update($index, $columns, $condition, $params, $options);
|
||||
return $this->setSql($sql)->bindValues($params);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace yii\sphinx;
|
||||
* @property QueryBuilder $queryBuilder The query builder for this Sphinx connection. This property is
|
||||
* read-only.
|
||||
* @method Schema getSchema() The schema information for this Sphinx connection
|
||||
* @method QueryBuilder getQueryBuilder() he query builder for this Sphinx connection
|
||||
* @method QueryBuilder getQueryBuilder() the query builder for this Sphinx connection
|
||||
*
|
||||
* @author Paul Klimov <klimov.paul@gmail.com>
|
||||
* @since 2.0
|
||||
|
||||
@@ -204,9 +204,10 @@ class QueryBuilder extends Object
|
||||
* refer to [[Query::where()]] on how to specify condition.
|
||||
* @param array $params the binding parameters that will be modified by this method
|
||||
* so that they can be bound to the DB command later.
|
||||
* @param array $options list of options in format: optionName => optionValue
|
||||
* @return string the UPDATE SQL
|
||||
*/
|
||||
public function update($index, $columns, $condition, &$params)
|
||||
public function update($index, $columns, $condition, &$params, $options)
|
||||
{
|
||||
if (($indexSchema = $this->db->getIndexSchema($index)) !== null) {
|
||||
$columnSchemas = $indexSchema->columns;
|
||||
@@ -241,7 +242,14 @@ class QueryBuilder extends Object
|
||||
|
||||
$sql = 'UPDATE ' . $this->db->quoteIndexName($index) . ' SET ' . implode(', ', $lines);
|
||||
$where = $this->buildWhere($condition, $params);
|
||||
return $where === '' ? $sql : $sql . ' ' . $where;
|
||||
if ($where !== '') {
|
||||
$sql = $sql . ' ' . $where;
|
||||
}
|
||||
$option = $this->buildOption($options, $params);
|
||||
if ($option !== '') {
|
||||
$sql = $sql . ' ' . $option;
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user