From 1ad689299b84ee9de23df27748e832de3d7eca2b Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Tue, 18 Jul 2017 18:36:46 +0000 Subject: [PATCH] modelGenerator: create automatillay foreign objects if needed git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3812 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- tools/modelGenerator.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/modelGenerator.php b/tools/modelGenerator.php index 0d781f1..473ff69 100755 --- a/tools/modelGenerator.php +++ b/tools/modelGenerator.php @@ -158,6 +158,20 @@ class modelGenerator implode ("\", \"", $params). "\"),\n"; $f .= " ));\n"; + + $f .= "\n"; + $f .= " // And the associated objects\n"; + if ($this->namespaceName === false) + $path = "\\models\\"; + elseif ($this->namespaceName !== "") + $path = "\\$this->namespaceName\\"; + else + $path = ""; + foreach ($schema["foreign"] as $field=>$params) + { + $f .= " \$this->foreign_$field = new $path$field ();\n"; + $f .= " \$this->setForeignObj (\$this->foreign_$field);\n"; + } } $f .= " }\n";