-
Notifications
You must be signed in to change notification settings - Fork 114
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
Database + table name #93
Comments
The library appears to support this through the The only problem is, it seems that the query builder class does not expose this functionality. The @nilportugues Do I understand correctly? If so, what approach would you prefer for solving this? I would be interested in writing a patch for to fix this. |
The Table class supports aliases and schemas, but the query builder and syntax builder required string parameters instead. The easiest way to add support for table alias and multiple database schema queries without changing the API, is to allow Table objects to be passed to setTable() and related methods. Also: - docs: Fix `@return` of AbstractBaseQuery::getTable. - docs: Fix `@param $table` of AbstractBaseQuery::orderBy. - minor: Remove redundant `array()` wrap on table names from AbstractBaseQuery to SyntaxFactory::createTable, and from Column to SyntaxFactory::createTable. - Column: Fix bug where `(string) $table` caused alias and schema to be lost, due to unexpected Table being casted to plain name via Table::__toString. Ref nilportugues#93.
The Table class supports aliases and schemas, but the query builder and syntax builder required string parameters instead. The easiest way to add support for table alias and multiple database schema queries without changing the API, is to allow Table objects to be passed to setTable() and related methods. Also: - docs: Fix `@return` of AbstractBaseQuery::getTable. - docs: Fix `@param $table` of AbstractBaseQuery::orderBy. - minor: Remove redundant `array()` wrap on table names from AbstractBaseQuery to SyntaxFactory::createTable, and from Column to SyntaxFactory::createTable. - Column: Fix bug where `(string) $table` caused alias and schema to be lost, due to unexpected Table being casted to plain name via Table::__toString. Ref nilportugues#93.
@andybee we use query builder in association with PDO, hence we sconnect and select the database through PDO, before using query builder. You can try that as well, hope this answer is not too late? |
@marcus-hiles The issue I was experiencing is that in our multi-tenant environment (where we use databases to separate concerns), the same script may need to use multiple different databases and re-establishing the connection to the server just to switch DB would be inefficient. |
Oh ok, gotcha @andybee |
I was expecting to be able to build a query along the lines of:
$queryBuilder->select()->setTable('users.user');
Where the table
user
exists within a databaseusers
.Am I missing an undocumented method that lets me set the DB another way, or do I have to apply a
USE
SQL command ahead of running the query?The text was updated successfully, but these errors were encountered: