| @@ 153-161 (lines=9) @@ | ||
| 150 | $tokens = []; |
|
| 151 | $tokens_counter = 0; |
|
| 152 | $a = 0; |
|
| 153 | foreach ($fields_values as $field => $value) { |
|
| 154 | if ($a) { |
|
| 155 | $update .= ', '; |
|
| 156 | } |
|
| 157 | ++$a; |
|
| 158 | ++$tokens_counter; |
|
| 159 | $update .= '`' . $field . '` = :' . $tokens_counter; |
|
| 160 | $tokens[':' . $tokens_counter] = $value; |
|
| 161 | } |
|
| 162 | ||
| 163 | //Where |
|
| 164 | $a = 0; |
|
| @@ 166-176 (lines=11) @@ | ||
| 163 | //Where |
|
| 164 | $a = 0; |
|
| 165 | $where = ''; |
|
| 166 | foreach ($where_fields_values as $field => $value) { |
|
| 167 | if ($a) { |
|
| 168 | $where .= ' AND '; |
|
| 169 | } else { |
|
| 170 | ++$a; |
|
| 171 | $where .= 'WHERE '; |
|
| 172 | } |
|
| 173 | ++$tokens_counter; |
|
| 174 | $where .= '`' . $field . '`= :' . $tokens_counter; |
|
| 175 | $tokens[':' . $tokens_counter] = $value; |
|
| 176 | } |
|
| 177 | ||
| 178 | $query = 'UPDATE `' . $table . '` SET ' . $update . ' ' . $where; |
|
| 179 | try { |
|