|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
||||
|
||||
|
MDB2 | Retrieving table description / declaration
Since PEAR:
B is being phased out, I figured I'd get the hang of MDB2 so I can migrate all things that need migrating.Is there any SQL dialect-agnostic way in MDB2 to retrieve the declaration of a table? I'm hoping for a method somewhere that takes the name of a table, and returns an associative array, with each element being an array describing a field. Does MDB2 offer such a feature, or am I stuck with vendor-specific queries like the following? Code:
SHOW COLUMNS FROM sometable
__________________
"A poor programmer is he who blames his tools." http://analyser.oli.tudelft.nl/ |
|
#2
|
||||
|
||||
|
HI Analyser
So your wanting the table description or a mysqldump of the table to then re-import? Can you just just use a query and execute it using the exec() function in MDB2? |
|
#3
|
|||
|
|||
|
Why is this in PHP development?
|
|
#4
|
||||
|
||||
|
MDB2 is writtin in PHP? And if you put it in SQL no one would know what you are talking about - maybe.
|
|
#5
|
||||
|
||||
|
This is in the PHP forum instead of the MySQL forum because I'm asking if a library written in PHP supports a certain feature.
Basically, what I want is to tell MDB2, "Here's a DSN, and a table name. Which columns does the table have, and what are their types?". I could of course, like I already mentioned, use a vendor specific query. If it were a table in a MySQL database, I could use a "DESCRIBE sometable;" query. That's all fine and dandy, but if I migrate my application to PostgreSQL or MS SQL Server, I'm screwed. The whole point is that I don't want to have to care what database the table is in; MDB2 is a db abstraction layer; does it abstract this away too, or doesn't it? So, once again, I'm looking for a way to retrieve a table's definition in a generic way, without having to care which vendor it is from. |
|
#6
|
||||
|
||||
|
No clue if this is of help, but a quick google and a couple of clicks found:
Quote:
Quote:
__________________
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer" - Bruce Graham |
|
#7
|
||||
|
||||
|
That's -exactly- what I was looking for! Thank you, Simon!
I'll have to remember that MDB2 apparently puts all these nifty advanced features in "modules". The Reverse module does exactly what I want; it has a tableInfo() method that returns an associative array of all the table's fields. I've already got some testcode up and running. Now to find out how cross-platform this feature really is... ![]() Again, thanks for the help, Simon! |
|
#8
|
|||
|
|||
|
Happy to help!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > MDB2 | Retrieving table description / declaration |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|