Created
May 27, 2012 16:50
-
-
Save sycobuny/2815045 to your computer and use it in GitHub Desktop.
A good _QueryTable class?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class _QueryTable extends _QueryTableExpression { | |
private $identifier; | |
function __construct($identifier, $alias = null) { | |
$this->identifier = _QueryIdentifier::create($identifier, $alias); | |
} | |
public static function create($identifier, $alias = null) { | |
// this is probably a self-join that's aliased. | |
if ($alias) { | |
return new _QueryTable($identifier, $alias); | |
} | |
// from here on out, don't bother checking for aliases. | |
// any table expression is a stand-in for a table | |
if (is_a($identifier, '_QueryTableExpression')) { | |
return $identifier; | |
} | |
// pass off handling to the constructor | |
else { | |
return new _QueryTable($identifier); | |
} | |
} | |
public function sql_string() { | |
return $this->do_alias($this->identifier->sql_string()); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment