A little bug : if we don't modify the uniq columns, no need to check if there is a constrain violation

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1239 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-03-23 19:09:42 +00:00
parent 04e13afe42
commit bd575e67ed

View File

@@ -246,21 +246,29 @@ class dblayer extends PDO
if (is_array ($columns))
{
$select = array ();
$select[] = array ($this->primary, $updatekey, "!=");
foreach ($columns as $col)
{
if (!array_key_exists ($col, $datasOK)) continue;
$select[] = array ($col, $datasOK[$col]);
}
$rc = $this->read ($select, array ($this->primary));
if (count ($rc) > 0)
throw new Exception (sprintf (
// If there is only the primary key, there is no chance to have a
// conflict
if (count ($select) >= 2)
{
$rc = $this->read ($select, array ($this->primary));
if (count ($rc) > 0)
throw new Exception (sprintf (
_("The provided value for columns '%s' already exists"),
implode (",", $columns)), 405);
}
}
else
{
if (!array_key_exists ($columns, $datasOK)) continue;
$rc = $this->read (array (array ($columns, $datasOK[$columns])),
$rc = $this->read (array (array ($columns, $datasOK[$columns]),
array ($this->primary, $updatekey, "!=")),
array ($this->primary));
if (count ($rc) > 0)
throw new Exception (sprintf (