MCPcopy Create free account
hub / github.com/EqualifyEverything/equalify / update_db_entry

Method update_db_entry

models/db.php:529–555  ·  view source on GitHub ↗

* Update DB Entry * @param string table * @param string id * @param array fields * [ array('name' => $name, 'value' => $value) ] */

($table, $id, array $fields)

Source from the content-addressed store, hash-verified

527 * [ array('name' => $name, 'value' => $value) ]
528 */
529 public static function update_db_entry($table, $id, array $fields)
530 {
531
532 // Prepare the UPDATE SQL.
533 $sql = 'UPDATE `'.$table.'` SET ';
534 $field_count = count($fields);
535 $params = array();
536 $counter = 0;
537 foreach($fields as $field){
538 $counter++;
539 $sql.= $field['name'].' = ?';
540 if($counter !== $field_count)
541 $sql.= ', ';
542 $params[] = $field['value'];
543 }
544
545 // Finish up the SQL.
546 $sql.= ' WHERE id = ?';
547 $params[] = $id;
548
549 // Query
550 $result = self::query($sql, $params, true);
551
552 // Complete Query
553 return $result;
554
555 }
556
557 /**
558 * Delete DB Entries

Callers 2

activate_alert.phpFile · 0.80
ignore_alert.phpFile · 0.80

Calls 1

queryMethod · 0.95

Tested by

no test coverage detected