@@ 769-786 (lines=18) @@ | ||
766 | * @param array $options Additional options for the query. |
|
767 | * @return string Returns the update statement as a string. |
|
768 | */ |
|
769 | protected function buildUpdate($tablename, array $set, array $where, $quotevals = true, array $options = []) { |
|
770 | $sql = 'update '. |
|
771 | (val(Db::OPTION_IGNORE, $options) ? 'ignore ' : ''). |
|
772 | $this->backtick($this->px.$tablename). |
|
773 | "\nset\n "; |
|
774 | ||
775 | $parts = []; |
|
776 | foreach ($set as $key => $value) { |
|
777 | $parts[] = $this->backtick($key).' = '.$this->quoteVal($value, $quotevals); |
|
778 | } |
|
779 | $sql .= implode(",\n ", $parts); |
|
780 | ||
781 | if (!empty($where)) { |
|
782 | $sql .= "\nwhere ".$this->buildWhere($where, Db::OP_AND, $quotevals); |
|
783 | } |
|
784 | ||
785 | return $sql; |
|
786 | } |
|
787 | ||
788 | /** |
|
789 | * {@inheritdoc} |
@@ 143-160 (lines=18) @@ | ||
140 | /** |
|
141 | * {@inheritdoc} |
|
142 | */ |
|
143 | protected function buildUpdate($tablename, array $set, array $where, $quotevals = true, array $options = []) { |
|
144 | $sql = 'update '. |
|
145 | (val(Db::OPTION_IGNORE, $options) ? 'or ignore ' : ''). |
|
146 | $this->backtick($this->px.$tablename). |
|
147 | "\nset\n "; |
|
148 | ||
149 | $parts = []; |
|
150 | foreach ($set as $key => $value) { |
|
151 | $parts[] = $this->backtick($key).' = '.$this->quoteVal($value, $quotevals); |
|
152 | } |
|
153 | $sql .= implode(",\n ", $parts); |
|
154 | ||
155 | if (!empty($where)) { |
|
156 | $sql .= "\nwhere ".$this->buildWhere($where, Db::OP_AND, $quotevals); |
|
157 | } |
|
158 | ||
159 | return $sql; |
|
160 | } |
|
161 | ||
162 | /** |
|
163 | * Construct a column definition string from an array defintion. |