Re: DB_DataObject - Table alias in joined query

From: Date: Wed, 23 Aug 2006 08:44:36 +0000
Subject: Re: DB_DataObject - Table alias in joined query
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-24965@lists.php.net to get a copy of this message
> Doing this : > <?php > $cat = & DB_DataObject::factory('ent_categorie'); > $fcat = & DB_DataObject::factory('ent_categorie'); > > $cat->selectAdd(); > $cat->selectAdd('ent_categorie.*'); > $cat->joinAdd($fcat,'right','fcat'); > > $cat->selectAs($fcat,'ent_categorie__%s'); > ?> > This is still not what I need. The alias is used for the WHERE > clause, not for the select fields. > What I would want is : > SELECT ent_categorie.* , fcat.id as ent_categorie__id , fcat.titre as > ent_categorie__titre , fcat.strip as > ent_categorie__strip ,fcat.active as ent_categorie__active , > fcat.categorie_id as ent_categorie__categorie_id , fcat.gauche as > ent_categorie__gauche , fcat.droite as ent_categorie__droite , > fcat.path as ent_categorie__path > FROM ent_categorie > LEFT JOIN entada.ent_categorie AS fcat ON > fcat.id=ent_categorie.categorie_id > > I've tried different ways using joinAdd(), selectAs(), selectAdd() > but never achieved my goal Hmmh, how about this one: $do = DB_DataObject::factory('tableName'); $linkDo = DB_DataObject::factory('tableName'); $do->joinAdd($linkDo, 'LEFT', 'tableAlias'); $do->selectAs($linkDo, 'tableAlias_%s', 'tableAlias'); This seems to work here in a different context. Cheers Jan -- Jan Wagner <wagner@netsols.de> netsols.de

« previous php.pear.general (#24965) next »