Re: [DB] Suggestion for field types

From: Date: Fri, 09 Jan 2004 01:55:06 +0000
Subject: Re: [DB] Suggestion for field types
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-24917@lists.php.net to get a copy of this message
Hi again Hans. Well I have done some tests, and using a two table join, I get the columns types and lengths back when using mysql, pgsql and Informix backends, by doing a call to tableInfo() after calling query(). So no additional query is needed, as far as I can tell. What do you get if you do: $res = $db->query('sel...'); $tinfo = $res-tableInfo(); print_r($tinfo); ? Kind regards, Peter Hans Lellelid wrote: > >I'm not sure I understand you here. I am getting metadata back when using PEAR to > >mysql, pgsql, and informix databases, as a result of a call to $db->query(). This allows me to > >display the colomn names for say 'select name, title from guys', where that sql is > >composed by the user. > > > Ok ... maybe I'm not understanding you here either. :) Certainly you > can get the column names (e.g. as keys of mysql_fetch_assoc() result) > when you use $db->query("SELECT name, title FROM guys") but you don't > know that name is a "string" (or better yet, "VARCHAR(100)") based on > the simple resultset, right? If you wanted to find out the database > types of the columns in the resultset you'd have to do an additional > query -- and of course this immediately gets very complicated when you > have multi-table queries, SQL functions, etc. >

« previous php.pear.dev (#24917) next »