Re: $db->tableInfo(); (PEAR::DB)
| From: | Joao Prado Maia | Date: | Thu, 13 Sep 2001 15:56:24 +0000 |
| Subject: | Re: $db->tableInfo(); (PEAR::DB) | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-1902@lists.php.net to get a copy of this message | ||
On 13 Sep 2001, Marc Logemann wrote:
> Hi,
>
> we are currently switching our very own recordSet class
> to PEAR/DB. In this recordSet class we use a lot of
> database functions, so we needed to take a deep look into
> pear/db.
>
> I have questions regarding tableinfo() method, it gives
> back an multi-dim. assoc array with fieldinformations, so far so good.
> One entry in this array is [flags].
>
> for mysql, this would give back things like "primary_key" or
> "auto_increment" ...
>
> i wonder what other databases give back, i doubt that not all
> would return "primary_key" but perhaps "pk" instead.
>
> If this should be the case, wouldnt it be useful to abstract
> also this kind of data/flags, because i dont want to make the abstraction
> in my application of course.
>
> right now i do something like: if($hashmap[0][flags]=="primary_key")
>
> if a database would return "pk", i would have serious problems, and the
> whole abstraction would break down.
>
> can anyone comment on this?
>
We are also using the tableInfo method in our company to build some custom
intranet screens to edit raw data out of our tables and I also experienced
the same problems as you did.
In an ideal world, we would get the table information by doing "DESC
tablename" of sorts, and build the array manually, since I believe that
MySQL and Oracle have very different ways to report the column
information.
The mysql version of tableInfo() currently uses mysql_list_fields() and
mysql_*fields* functions. The problem here is that a BLOB column for
instance is the same as a TEXT column, but the difference is inside the
'flags' index, which contains 'binary' on those cases. It would be nice to
abstract that to the actual datatypes of the fields.
Cheers,
Joao
--
João Prado Maia <jpm@phpbrasil.com>
http://phpbrasil.com - php com um jeitinho brasileiro
--
Precisando de consultoria em desenvolvimento para a Internet ?
Impleo.net - http://impleo.net/?lang=br