function setTable($table_name, $alias = null) {
		if ($table_name instanceof Query) {
			if (!$alias) {
				throw new RuntimeException('The nested query must have an alias.');
			}
			$table_name = clone $table_name;
		} elseif (null === $alias) {
			$space = strrpos($table_name, ' ');
			$as = strrpos(strtoupper($table_name), ' AS ');
			if ($as != $space - 3) {
				$as = false;
			}
			if ($space) {
				$alias = trim(substr($table_name, $space + 1));
				$table_name = trim(substr($table_name, 0, $as === false ? $space : $as));
			}
		}

		if ($alias) {
			$this->setAlias($alias);
		}

		$this->table = $table_name;
		return $this;
	}
function setTable($table_name, $alias = null) {
		if ($table_name instanceof Query) {
			if (!$alias) {
				throw new RuntimeException('The nested query must have an alias.');
			}
			$table_name = clone $table_name;
		} elseif (null === $alias) {
			$space = strrpos($table_name, ' ');
			$as = strrpos(strtoupper($table_name), ' AS ');
			if ($as != $space - 3) {
				$as = false;
			}
			if ($space) {
				$alias = trim(substr($table_name, $space + 1));
				$table_name = trim(substr($table_name, 0, $as === false ? $space : $as));
			}
		}

		if ($alias) {
			$this->setAlias($alias);
		}

		$this->table = $table_name;
		return $this;
	}
function setTable ( $ table_name , $ alias = null ) { if ( $ table_name instanceof Query ) { if ( ! $ alias ) { throw new RuntimeException ( 'The nested query must have an alias.' ) ; } $ table_name = clone $ table_name ; } elseif ( null === $ alias ) { $ space = strrpos ( $ table_name , ' ' ) ; $ as = strrpos ( strtoupper ( $ table_name ) , ' AS ' ) ; if ( $ as != $ space - 3 ) { $ as = false ; } if ( $ space ) { $ alias = trim ( substr ( $ table_name , $ space + 1 ) ) ; $ table_name = trim ( substr ( $ table_name , 0 , $ as === false ? $ space : $ as ) ) ; } } if ( $ alias ) { $ this -> setAlias ( $ alias ) ; } $ this -> table = $ table_name ; return $ this ; }
Sets the table to be queried. This can be a string table name
or an instance of Query if you would like to nest queries.
This function also supports arbitrary SQL.

@param String|Query $table_name Name of the table to add, or sub-Query
@param String[optional] $alias Alias for the table
@return Query
Sets the table to be queried . This can be a string table name or an instance of Query if you would like to nest queries . This function also supports arbitrary SQL .