diff --git a/dblayeroo.php b/dblayeroo.php index 2a9c17d..11fd341 100644 --- a/dblayeroo.php +++ b/dblayeroo.php @@ -1313,6 +1313,7 @@ class dblayeroo $this->DBException ( "Invalid object provided to setForeignObj (no table defined)"); $this->setForeignObj[$object->tableprefix.$object->table] = $object; + return $this; } /* }}} */ @@ -2262,9 +2263,10 @@ class dblayeroo // - If foreign keys, check if the value is set in the constraint foreach ($this->foreign as $field=>$params) { - if (! array_key_exists ($field, $this->setValues)) - $errors[$field] = dgettext ("domframework", - "The field '%s' must be test on foreign, but is not provided"); + if (! array_key_exists ($field, $values)) + $errors[$field] = sprintf (dgettext ("domframework", + "The field '%s' must be test on foreign, but is not provided"), + $field); if (! array_key_exists ($params[0], $this->setForeignObj)) $this->DBException (dgettext ("domframework", "No foreign object configured to test the foreign key")); @@ -2275,7 +2277,7 @@ class dblayeroo $objTmp->clearRequest (); $objTmp->Select (); $objTmp->displayAdd ($objTmp->primary); - $objTmp->whereAdd ($params[1], "=", $this->setValues[$field]); + $objTmp->whereAdd ($params[1], "=", $values[$field]); if (count ($objTmp->execute ()) === 0) $errors[$field] = sprintf (dgettext ("domframework", "The value of the foreign key '%s' doesn't exists in foreign table"),