-
Notifications
You must be signed in to change notification settings - Fork 398
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
Add getTableNames() in the DBAL of Propel #261
Comments
+1 for this |
👍 on this, but this is not a priority yet. |
Incredible this is not a priority! I'm almost changing into Doctrine for this question. |
@valle6 You can provide a pull request for that if you really need it. |
Mh, I don't see the benefit with that method here. We've already a powerful schema parser for mssql, mysql, oracle, pgsql and sqlite and should thus not write stuff twice. I think, improving the interface of |
So, $database = new Database();
$parser = new MysqlSchemaParser();
$parser->setConnection($conn);
$parse->parse($database);
$tables = $database->getTables(); So, this is already possible with all databases and even more powerful as you have all information of the whole database, with its tables, columns, foreignKeys, indices, etc. Indeed it's a bit more to write, but a shortcut at $conn would be fine to me. Feel free to send a PR. :-) |
Ok, it's a easy-pick now, since its really only a method that fires those ~5 lines of code above to have a easier api. |
@marcj A late call here. I still don't get it why the following is not working
|
as i read this issue again i notice:
from my point of view this is a no go, if i want to get the table names i don't want to hardcode which database i am using also from the DX it should be as easy as '$connection->getTableNames();' |
Actually needless to say, but for you: Of course it's not hardcoded, but connection dependent. |
the propelbundle uses the
SHOW TABLES
to get all table names, which is mysql (only). it won't work in postgresql and in sqlite.propelorm/PropelBundle#164
sometimes you get in the situation, that you need to get the table names in your application, this should be handled by the DBAL = Propel
would be good to have something like
i think it's not that difficult to research it for all databases. where should the $xxx->getTableNames() be added? to the connection? $con->getTableNames()?
Postgres
postgres equivalent for
SHOW TABLES
isthe problem with both commands are, that they are also listing internal table schemas( pg_catalog and infromation_schema).
so you can hardcode a little bit like this:
but then you force the user to use the public schema. how is the support of postgres schemas in propel? if there is any schema support we maybe can use it for this.
infos partly from http://stackoverflow.com/questions/769683/show-tables-in-postgresql
what also would be possible is to make something like this:
all the system tables are owned by the postgres user, so sleecting by
my_symyony_db_user
should work. also by selecting by "not" works:Sqlite
for sqlite the command is (tested with sqlitemanager in firefox on windows)
SELECT name FROM sqlite_master WHERE type='table'
general command:
SELECT * FROM dbname.sqlite_master WHERE type='table';
http://stackoverflow.com/questions/82875/how-do-i-list-the-tables-in-a-sqlite-database-file
The text was updated successfully, but these errors were encountered: