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:
10
dblayer.php
10
dblayer.php
@@ -246,21 +246,29 @@ class dblayer extends PDO
|
|||||||
if (is_array ($columns))
|
if (is_array ($columns))
|
||||||
{
|
{
|
||||||
$select = array ();
|
$select = array ();
|
||||||
|
$select[] = array ($this->primary, $updatekey, "!=");
|
||||||
foreach ($columns as $col)
|
foreach ($columns as $col)
|
||||||
{
|
{
|
||||||
if (!array_key_exists ($col, $datasOK)) continue;
|
if (!array_key_exists ($col, $datasOK)) continue;
|
||||||
$select[] = array ($col, $datasOK[$col]);
|
$select[] = array ($col, $datasOK[$col]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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));
|
$rc = $this->read ($select, array ($this->primary));
|
||||||
if (count ($rc) > 0)
|
if (count ($rc) > 0)
|
||||||
throw new Exception (sprintf (
|
throw new Exception (sprintf (
|
||||||
_("The provided value for columns '%s' already exists"),
|
_("The provided value for columns '%s' already exists"),
|
||||||
implode (",", $columns)), 405);
|
implode (",", $columns)), 405);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!array_key_exists ($columns, $datasOK)) continue;
|
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));
|
array ($this->primary));
|
||||||
if (count ($rc) > 0)
|
if (count ($rc) > 0)
|
||||||
throw new Exception (sprintf (
|
throw new Exception (sprintf (
|
||||||
|
|||||||
Reference in New Issue
Block a user