Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functionality to use foreignSchema attribute of foreign-key tag… #1674

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Propel/Generator/Model/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,18 @@ public function getTable($name, $caseInsensitive = false)
&& strpos($name, $this->getPlatform()->getSchemaDelimiter()) === false
) {
$name = $this->getSchema() . $this->getPlatform()->getSchemaDelimiter() . $name;
} else if (strpos($name, '.') !== false){
/*
For pgSql and other dbs which support schemas, getSchema will work exactly as expected.
For other dbs, the <foreign-key foreignSchema="" > attribute can be used to link to databases within the same propel projec
*/
$db = explode(".", $name)[0];
$name = explode(".", $name)[1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[$db, $name] = explode(..., ..., 2) is the better syntax here.


$sc = $this->getParentSchema();
$db = $sc->getDatabase($db, false);

return $db->getTable($name);
}

if (!$this->hasTable($name, $caseInsensitive)) {
Expand Down