/** * update a record * @param array $p array with properties (id field is required for update) * @return boolean */ public static function update($p) { parent::update($p); $p = array_intersect_key($p, static::$tableFields); $assignments = array(); $values = array($p['id']); $p['type'] = static::$type; $i = 2; foreach ($p as $k => $v) { switch ($k) { case 'id': break; case 'password': $assignments[] = "`{$k}` = MD5(CONCAT('aero', \$" . $i++ . "))"; $values[] = $v; break; default: $assignments[] = "`{$k}` = \$" . $i++; $values[] = $v; break; } } //prepare sql $sql = 'UPDATE `' . static::$tableName . '` ' . ' SET ' . implode(',', $assignments) . ' WHERE id = $1'; //add database record DB\dbQuery($sql, $values) or die(DB\dbQueryError()); $rez = DB\dbAffectedRows() > 0; return $rez; }
/** * update core record form __casebox.cores table * @param array $p * @return array | null */ public static function update($p) { if (empty($p['id'])) { $p['id'] = static::toId($p['name']); } $rez = parent::update($p); return $rez; }
/** * update a record * @param array $p array with properties (id field is required for update) * @return boolean */ public static function update($p) { $p['type'] = static::$type; $rez = parent::update($p); return $rez; }