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";