dblayeroo: verify foreign keys are skipped if update and the value is not provided
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3793 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -2532,7 +2532,7 @@ class dblayeroo
|
|||||||
// Do not test in update if the field is not provided as it was already
|
// Do not test in update if the field is not provided as it was already
|
||||||
// recorded
|
// recorded
|
||||||
if ($update === true && ! array_key_exists ($field, $values))
|
if ($update === true && ! array_key_exists ($field, $values))
|
||||||
continue;
|
continue 2;
|
||||||
if (! array_key_exists ($field, $values))
|
if (! array_key_exists ($field, $values))
|
||||||
{
|
{
|
||||||
$errors[$field] = sprintf (dgettext ("domframework",
|
$errors[$field] = sprintf (dgettext ("domframework",
|
||||||
@@ -2554,7 +2554,12 @@ class dblayeroo
|
|||||||
$objTmp->displayAdd ($objTmp->primary);
|
$objTmp->displayAdd ($objTmp->primary);
|
||||||
$parentField = explode (",", $params[1]);
|
$parentField = explode (",", $params[1]);
|
||||||
foreach (explode (",", $fields) as $key=>$field)
|
foreach (explode (",", $fields) as $key=>$field)
|
||||||
|
{
|
||||||
|
if (! key_exists ($field, $values))
|
||||||
|
$this->DBException (sprintf (dgettext ("domframework",
|
||||||
|
"Can't check the foreign value for '%s': not provided"), $field));
|
||||||
$objTmp->whereAdd ($parentField[$key], "=", $values[$field]);
|
$objTmp->whereAdd ($parentField[$key], "=", $values[$field]);
|
||||||
|
}
|
||||||
if (count ($objTmp->execute ()) === 0)
|
if (count ($objTmp->execute ()) === 0)
|
||||||
$errors[$field] = sprintf (dgettext ("domframework",
|
$errors[$field] = sprintf (dgettext ("domframework",
|
||||||
"The value of the foreign key '%s' doesn't exists in foreign table"),
|
"The value of the foreign key '%s' doesn't exists in foreign table"),
|
||||||
|
|||||||
Reference in New Issue
Block a user