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