/** * Update row corresponding to $aValues[$pk] * @param string $table * @param array $aValues Array of couple field => value * @param string $pk Primary key field * @return mixed */ public function update($table, $aValues, $pk) { $sql = "\n UPDATE\n " . $this->quoteTable($table) . "\n SET\n "; $aSet = array(); $bind = array(); foreach ($aValues as $f => $v) { $k = CString::sanitize($f); $aSet[] = $this->quoteField($f) . " = :v{$k}"; $bind[":v" . $k] = $v; } $sql .= " " . implode(", ", $aSet) . " "; $sql .= " WHERE " . $this->quoteField($pk) . " = :pk"; $bind[":pk"] = $aValues[$pk]; $this->query($sql, $bind); return $aValues[$pk]; //$this->getLastInsertedId(); }