Re: ibase_fetch_object & ibase_fetch_row

From: Date: Thu, 18 Oct 2001 00:49:18 +0000
Subject: Re: ibase_fetch_object & ibase_fetch_row
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-71429@lists.php.net to get a copy of this message
On Thu, 18 Oct 2001 02:09, V wrote: > I'm working with php and interbase. I know most of you work with mysql, > i have no idea of mysql. > > My problem: When i try to use ibase_fetch_object, it works fine if > there is no fields with the same name from different tables. I mean: > > $mysql="SELECT NAME,DESCRIPTION > FROM PRODUCTS > WHERE ID_PRODUCT=$id_product"; > $myquery=ibase_query($myconnection,$mysql); > $myrow=ibase_fetch_object($myquery); > > Now i have $myrow->NAME and $myrow->DESCRIPTION. > > Ok. But if $mysql is a join like this one: > > $mysql="SELECT P.NAME,P.DESCRIPTION,G.NAME > FROM PRODUCTS P INNER JOIN GROUPS G > ON P.ID_GROUP=G.ID_GROUP > WHERE P.ID_PRODUCT=$id_product"; > $myquery=ibase_query($myconnection,$mysql); > $myrow=ibase_fetch_object($myquery); > > When i try to use $myrow->P.NAME it gives me error > If i tyr to use $myrow->NAME, i have the first NAME (the one from > PRODUCTS), never the second (the one from GROUPS). > > What can i do?. How can i retrieve GROUPS.NAME from this query?. I'm > using ibase_fetch_row, but it is not as clear as ibase_fetch_object. > Ibase should understand aliases - write your query as $mysql="SELECT P.NAME as pname,P.DESCRIPTION as pdesc,G.NAME as gname FROM PRODUCTS P INNER JOIN GROUPS G ON P.ID_GROUP=G.ID_GROUP WHERE P.ID_PRODUCT=$id_product"; Better still, redefine your column names so there is no ambiguity. Maybe something like prd_name and grp_name, to reflect the table they belong to. -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA HELP! I need a tagline. HELP! Not just any tagline.

« previous php.general (#71429) next »