diff --git a/dblayer.php b/dblayer.php index 88043d4..032e24a 100644 --- a/dblayer.php +++ b/dblayer.php @@ -398,16 +398,13 @@ class dblayer extends PDO } // If there is only the primary key, there is no chance to have a // conflict - if ($updatekey === false && count ($select) >= 2) + // Before updating, check if the new values are not creating an error + $rc = $this->read ($select, array ($this->primary)); + if (count ($rc) > 0) { - $rc = $this->read ($select, array ($this->primary)); - if (count ($rc) > 0) - { - $errors[] = array ("error", sprintf (dgettext("domframework", - "The provided values for columns '%s' already exists"), - implode (",", $columns))); - continue; - } + $errors[] = array ("error", dgettext("domframework", + "An entry with these values already exists")); + continue; } } else @@ -426,9 +423,8 @@ class dblayer extends PDO array ($this->primary)); if (count ($rc) > 0) { - $errors[] = array ("error", sprintf (dgettext("domframework", - "The column '%s' with this value already exists"), - $columns)); + $errors[] = array ("error", dgettext("domframework", + "An entry with this value already exists")); continue; } } @@ -452,8 +448,8 @@ class dblayer extends PDO if (! isset ($datas[$foreign][0])) { $errors[] = array ("error", sprintf (dgettext("domframework", - "The field type for column '%s' is not provided"), - $foreign)); + "The field type for column '%s' is not provided"), + $foreign)); return $errors; continue; }