]> git.pld-linux.org Git - packages/cacti.git/blame - database_autoincrement_corruption.patch
- corrected for PLD version
[packages/cacti.git] / database_autoincrement_corruption.patch
CommitLineData
8892e7d7
AM
1diff -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
4@@ -214,17 +214,21 @@
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) {
10 global $cnn_id;
11
12 while (list ($key, $value) = each ($array_items)) {
13 $array_items[$key] = "\"" . sql_sanitize($value) . "\"";
14 }
15
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);
18+
19+ if ($replace_result == 0) {
20+ return 0;
21+ }
22
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]);
This page took 0.068659 seconds and 4 git commands to generate.