1 diff -ruBbd cacti-0.8.6h/lib/database.php cacti-0.8.6h-patched/lib/database.php
2 --- cacti-0.8.6h/lib/database.php 2006-04-24 20:07:11.000000000 -0400
3 +++ cacti-0.8.6h-patched/lib/database.php 2006-04-24 20:04:26.000000000 -0400
5 @arg $table_name - the name of the table to make the replacement in
6 @arg $key_cols - the primary key(s)
7 @returns - the auto incriment id column (if applicable) */
8 -function sql_save($array_items, $table_name, $key_cols = "id", $autoinc = TRUE) {
9 +function sql_save($array_items, $table_name, $key_cols = "id", $autoinc = true) {
12 while (list ($key, $value) = each ($array_items)) {
13 $array_items[$key] = "\"" . sql_sanitize($value) . "\"";
16 - if (!$cnn_id->Replace($table_name, $array_items, $key_cols, FALSE, $autoinc)) { return 0; }
17 + $replace_result = $cnn_id->Replace($table_name, $array_items, $key_cols, FALSE, $autoinc);
19 + if ($replace_result == 0) {
23 /* get the last AUTO_ID and return it */
24 - if ($cnn_id->Insert_ID() == "0") {
25 + if (($cnn_id->Insert_ID() == "0") || ($replace_result == 1)) {
26 if (!is_array($key_cols)) {
27 if (isset($array_items[$key_cols])) {
28 return str_replace("\"", "", $array_items[$key_cols]);