28 public function table( $table, $alias =
null ) {
30 if ( $alias ===
null ) {
31 $alias = $table->getAlias();
33 $table = $table->getRawTables();
35 if ( $alias ===
null ) {
38 $table =
new Subquery( $table->getSQL() );
39 } elseif ( !is_string( $table ) ) {
40 throw new \InvalidArgumentException( __METHOD__ .
41 ': $table must be either string, JoinGroup or SelectQueryBuilder' );
43 if ( $alias ===
null ) {
44 $this->tables[] = $table;
45 $this->lastAlias = $table;
47 $this->tables[$alias] = $table;
48 $this->lastAlias = $alias;
93 if ( !$this->tables ) {
94 throw new \LogicException( __METHOD__ .
95 ': cannot add a join unless a regular table is added first' );
97 if ( $alias ===
null ) {
98 if ( is_string( $table ) ) {
104 if ( isset( $this->joinConds[$alias] ) ) {
105 throw new \LogicException( __METHOD__ .
106 ": a join with alias \"$alias\" has already been added" );
109 $conflicts = array_intersect_key( $this->joinConds, $table->getRawJoinConds() );
111 $conflict = reset( $conflicts );
112 throw new \LogicException( __METHOD__ .
113 ": a join with alias \"$conflict\" has already been added" );
115 $this->tables[$alias] = $table->getRawTables();
116 $this->joinConds += $table->getRawJoinConds();
118 $this->tables[$alias] =
new Subquery( $table->getSQL() );
119 } elseif ( is_string( $table ) ) {
120 $this->tables[$alias] = $table;
122 throw new \InvalidArgumentException( __METHOD__ .
123 ': $table must be either string, JoinGroup or SelectQueryBuilder' );
126 $this->lastAlias = $alias;