function editRow($table, $vars, $nulls, $format, $types, $keyarr)
{
if (!is_array($vars) || !is_array($nulls) || !is_array($format) || !is_array($types)) {
return -1;
} else {
$f_schema = $this->_schema;
$this->fieldClean($f_schema);
$this->fieldClean($table);
// Build clause
if (sizeof($vars) > 0) {
foreach ($vars as $key => $value) {
$this->fieldClean($key);
// Handle NULL values
if (isset($nulls[$key])) {
$tmp = 'NULL';
} else {
$tmp = $this->formatValue($types[$key], $format[$key], $value);
}
if (isset($sql)) {
$sql .= ", \"{$key}\"={$tmp}";
} else {
$sql = "UPDATE \"{$f_schema}\".\"{$table}\" SET \"{$key}\"={$tmp}";
}
}
$first = true;
foreach ($keyarr as $k => $v) {
$this->fieldClean($k);
$this->clean($v);
if ($first) {
$sql .= " WHERE \"{$k}\"='{$v}'";
$first = false;
} else {
$sql .= " AND \"{$k}\"='{$v}'";
}
}
}
// Begin transaction. We do this so that we can ensure only one row is
// edited
$status = $this->beginTransaction();
if ($status != 0) {
$this->rollbackTransaction();
return -1;
}
$status = $this->execute($sql);
if ($status != 0) {
// update failed
$this->rollbackTransaction();
return -1;
} elseif ($this->conn->Affected_Rows() != 1) {
// more than one row could be updated
$this->rollbackTransaction();
return -2;
}
// End transaction
return $this->endTransaction();
}
}