[solved] A clean way to get at database table/column metadata?
Posted: Fri Aug 22, 2008 12:43 pm
Hi,
I'm looking for a clean (db independent) way of retrieving a database table's metadata, specifically a table's column names and associated datatypes. The adodb lite meta module isn't included in v1.4.1, so calls to the $db->MetaColumns() method are out. I searched the forums and found some people have tried manually parsing the output of db-specific "SHOW... " statements. That doesn't seem like a good long term solution. So, hearing about any other alternatives would be greatly appreciated!
If necessary, I'll create a feature request, but thought I'd check here first. ;)
Thanks!
Fred
P.S. As a side note: why do I want this?
My client maintains a lot of tabular data in multiple excel spreadsheets. They're currently using a custom app, that I wrote years ago, to generate a directory of static html pages from each spreadsheet file, based on a WYSIWYG template. It works, but they're getting overwhelmed with all the static pages. It's time to move them to a cms and make things simpler for them. The current plan is to provide them with 1) a simple way to import a spreadsheet into a db table and 2) a generic module/plugin that will query a table of their choice and display the data in a table with appropriate headings and pagination. To do the latter, I need to retrieve a table's column names, for use in headings, and datatypes, for proper formatting.
I'm looking for a clean (db independent) way of retrieving a database table's metadata, specifically a table's column names and associated datatypes. The adodb lite meta module isn't included in v1.4.1, so calls to the $db->MetaColumns() method are out. I searched the forums and found some people have tried manually parsing the output of db-specific "SHOW... " statements. That doesn't seem like a good long term solution. So, hearing about any other alternatives would be greatly appreciated!
If necessary, I'll create a feature request, but thought I'd check here first. ;)
Thanks!
Fred
P.S. As a side note: why do I want this?
My client maintains a lot of tabular data in multiple excel spreadsheets. They're currently using a custom app, that I wrote years ago, to generate a directory of static html pages from each spreadsheet file, based on a WYSIWYG template. It works, but they're getting overwhelmed with all the static pages. It's time to move them to a cms and make things simpler for them. The current plan is to provide them with 1) a simple way to import a spreadsheet into a db table and 2) a generic module/plugin that will query a table of their choice and display the data in a table with appropriate headings and pagination. To do the latter, I need to retrieve a table's column names, for use in headings, and datatypes, for proper formatting.