PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old May 8th, 2008, 09:17 AM
Analyser's Avatar
Analyser Analyser is offline
*bounce*
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Delft, The Netherlands
Posts: 509 Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 20 h 3 m 49 sec
Reputation Power: 9
Send a message via ICQ to Analyser
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/

Reply With Quote
  #2  
Old May 8th, 2008, 06:28 PM
jakenoble's Avatar
jakenoble jakenoble is offline
System.out.println("eh?");
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2004
Location: Derbyshire
Posts: 817 jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level)jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level)jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level)jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level)jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level)jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 10 h 8 m 25 sec
Reputation Power: 25
Send a message via MSN to jakenoble
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?

Reply With Quote
  #3  
Old May 8th, 2008, 07:43 PM
OlyPerson OlyPerson is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 37 OlyPerson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 34 m 41 sec
Reputation Power: 1
Why is this in PHP development?

Reply With Quote
  #4  
Old May 9th, 2008, 02:15 AM
jakenoble's Avatar
jakenoble jakenoble is offline
System.out.println("eh?");
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2004
Location: Derbyshire
Posts: 817 jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level)jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level)jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level)jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level)jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level)jakenoble User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 10 h 8 m 25 sec
Reputation Power: 25
Send a message via MSN to jakenoble
MDB2 is writtin in PHP? And if you put it in SQL no one would know what you are talking about - maybe.

Reply With Quote
  #5  
Old May 9th, 2008, 03:51 AM
Analyser's Avatar
Analyser Analyser is offline
*bounce*
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Delft, The Netherlands
Posts: 509 Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 20 h 3 m 49 sec
Reputation Power: 9
Send a message via ICQ to Analyser
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.

Reply With Quote
  #6  
Old May 9th, 2008, 06:07 AM
SimonJM SimonJM is online now
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 609 SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 23 h 38 m 9 sec
Reputation Power: 194
No clue if this is of help, but a quick google and a couple of clicks found:

Quote:
smith [AT] pooteeweet [DOT] org
2006-11-16 19:39:19 (222)

you need to use the manager and reverse modules:
http://pear.php.net/manual/en/package.database.mdb2.intro-module.php


Quote:
hdixon [at] deltabrahvo [DOT] com
2006-11-16 19:35:30 (221)

the h in ahvo is a blind ..

In any case: I don't seem to be able to query using DESCRIBE <table>, or
SHOW COLUMNS FROM <table> or find any references to an equivalent, via MDB2
- which means I'll end up having to write db-platform specific "get table
metadata" functions after all .. kinda defeats the purpose of MDB2,
surely?.. -

H
Comments on this post
Analyser agrees: The full 9 points for your google skillz... Thanks!
__________________
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer" - Bruce Graham

Reply With Quote
  #7  
Old May 9th, 2008, 07:12 AM
Analyser's Avatar
Analyser Analyser is offline
*bounce*
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Delft, The Netherlands
Posts: 509 Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 20 h 3 m 49 sec
Reputation Power: 9
Send a message via ICQ to Analyser
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!

Reply With Quote
  #8  
Old May 9th, 2008, 09:10 AM
SimonJM SimonJM is online now
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 609 SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 23 h 38 m 9 sec
Reputation Power: 194
Happy to help!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > MDB2 | Retrieving table description / declaration


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway