Reputation: 222
Is there a way to retrieve the column's comment (like from INFORMATION_SCHEMA.COLUMN table on MySQL) from a certain table without actually "hardcode" the query with Doctrine ORM?
Upvotes: 1
Views: 1419
Reputation: 222
Finally I found an way. what I was trying to do was get a column comment from inside a Controller
//lets say we have a table named 'product'
//and we want to get the comment from the 'name' column
//first we get a list of columns from 'product'
$columns = $this->getDoctrine()->getEntityManager()->getConnection()->getSchemaManager()->listTableColumns('product');
//then we just access getComment function from the 'Column' class
//for the 'name' column:
echo $columns['name']->getComment();
Upvotes: 3
Reputation: 20439
I doubt it, and the same would go for Propel as well. Both use PDO, and afaik there is no database-neutral way to do this.
To achieve this, you can often query the table columns using SELECT statements on system tables (certainly Oracle and PostgreSQL allow this). However, the names of the tables involved differ from one vendor to another. Here is how to get column names, for example, in PostgreSQL - getting comments would probably be quite similar.
It would be quite possible for an ORM to offer what you want, but the underlying implementation would be the approach I outline above. Perhaps you could request it on the Doctrine mailing list?
Upvotes: 0