public function update($table, $arFieldValues, $arConditions) { // tworzy tablicê dla klauzuli SET $arUpdates = array(); foreach($arFieldValues as $field => $val) { if(! is_numeric($val)) { // cytuje dane $val="'" . pg_escape_string($val) . "'"; } $arUpdates[] = "$field = $val"; } // tworzy tablicê dla klauzuli WHERE $arWhere = array(); foreach($arConditions as $field => $val) { if(! is_numeric($val)) { // cytuje dane $val = "'" . pg_escape_string($val) . "'"; } $arWhere[] = "$field = $val"; } $sql = "UPDATE $table SET "; $sql .= join(', ', $arUpdates); $sql .= ' WHERE ' . join(' AND ', $arWhere); $hRes = pg_query($sql); if(! is_resource($hRes)) { $err = pg_last_error($this->hConn) . NL . $sql; throw new Exception($err); } return pg_affected_rows($hRes); }
kubik1988elk