Re: DB_DataObject : table alias in joined queries
| From: | Alan Knowles | Date: | Tue, 22 Aug 2006 14:35:25 +0000 |
| Subject: | Re: DB_DataObject : table alias in joined queries | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-43775@lists.php.net to get a copy of this message | ||
Can you try diff -u, it's a bit easier to read.
It's probably better to use this (and never declare $_alias, to reduce the output from print_r()
function aliasAs($as = false) {
if ($as === false) {
return isset($this->_alias) ? $this->_alias : '';}
$this->_alias = $as;} I guess though the question is, why do you need to alias the base DataObject, when JoinAdd already provides aliasing for joined objects? Regards Alan arnaud sellenet wrote:
This is a diff between the current release and a version with added table alias for use in joined queries. Anyone interested ? 255a256,261/** * The table alias **/ var $_alias = '';420c426< ' FROM ' . ($quoteIdentifiers ? $DB->quoteIdentifier ($this->__table) : $this->__table) . " \n" .---' FROM ' . ($quoteIdentifiers ? $DB->quoteIdentifier ($this->__table) : $this->__table) . ' '. $this->_alias . " \n" .1517c1523,1525< $table = ($quoteIdentifiers ? $DB->quoteIdentifier($this- __table) : $this->__table);---$tablen = $this->_alias ? $this->_alias:$this->__table; $table = ($quoteIdentifiers ? $DB->quoteIdentifier ($tablen) : $tablen); $tablefrom = ($quoteIdentifiers ? ($DB->quoteIdentifier ($this->__table).' '.$DB->quoteIdentifier($this->_alias)) : ($this- __table.' '.$this->_alias));1529c1537< FROM $table {$t->_join} {$t->_query['condition']}");---FROM $tablefrom {$t->_join} {$t->_query ['condition']}");2427c2435 < ---$tablen = $this->_alias ? $this->_alias : $this->__table;2429,2430c2437,2438< ? ( $DB->quoteIdentifier($this->__table) . '.' . $DB->quoteIdentifier($k) ) < : "{$this->__table}.{$k}";---? ( $DB->quoteIdentifier($tablen) . '.' . $DB- quoteIdentifier($k) ) : "{$tablen}.{$k}";3156c3164< $table = $this->__table;---$table = $this->_alias?$this->_alias:$this->__table;3282c3290,3298 < ---/** * creates an table alias in the query * @param string the alias to use * @return null **/ function setAlias($alias) { $this->_alias = $alias; }