kohana / database

A Kohana module for database interactions, building queries, and prepared statements
http://kohanaframework.org/documentation
158 stars 140 forks source link

Why PDO driver doesn't allow list tables and columns #106

Open hkdobrev opened 8 years ago

hkdobrev commented 8 years ago
$this->_connection->query('SHOW TABLES')->fetchAll(\PDO::FETCH_COLUMN)

should work.

Any idea why it's made to throw an exception for the PDO driver?

shadowhand commented 8 years ago

Because PDO is not just MySQL: http://stackoverflow.com/questions/769683/show-tables-in-postgresql#769706

hkdobrev commented 8 years ago

Hmm, ok. Fair enough, but the database configuration states if it is MySQL or not. Can't we actually implement different queries based on the database specified in the DSN?

acoulton commented 8 years ago

@hkdobrev in principle I don't see why not, I think that could be useful. But it would need to be done in a clean, sensible way (potentially with some sort of sql abstraction class for each supported backend) and well-tested.

If you want to try it, then go ahead - I'd merge it as a new feature (for the 3.4 branch) if the implementation is OK. If not, then it's a nice idea but I can't promise anyone will have time or inclination to work on it.

Personally, I'd just add this at the application level if required, or use an existing more fully-featured DB abstraction package like Doctrine.

enov commented 8 years ago

There was a discussion about this in the old forums:

http://forum.kohanaframework.org/discussion/11921/best-way-to-save-a-11-relationship-using-the-kohana-orm