dblayer : Check before update if multiple unique keys are not used before doing the update
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1858 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
24
dblayer.php
24
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user