DB_dsql::table PHP Méthode

table() public méthode

Examples: $q->table('user'); $q->table('user','u'); $q->table('user')->table('salary') $q->table(array('user','salary')); $q->table(array('user','salary'),'user'); $q->table(array('u'=>'user','s'=>'salary')); If you specify multiple tables, you still need to make sure to add proper "where" conditions. All the above examples return $q (for chaining) You can also call table without arguments, which will return current table: echo $q->table(); If multiple tables are used, "false" is returned. Return is not quoted. Please avoid using table() without arguments as more tables may be dynamically added later.
public table ( string $table = UNDEFINED, string $alias = UNDEFINED )
$table string Specify table to use
$alias string Specify alias for the table
    public function table($table = UNDEFINED, $alias = UNDEFINED)
    {
        if ($table === UNDEFINED) {
            return $this->main_table;
        }
        if (is_array($table)) {
            foreach ($table as $alias => $t) {
                if (is_numeric($alias)) {
                    $alias = UNDEFINED;
                }
                $this->table($t, $alias);
            }
            return $this;
        }
        // main_table tracking allows us to
        if ($this->main_table === null) {
            $this->main_table = $alias === UNDEFINED || !$alias ? $table : $alias;
        } elseif ($this->main_table) {
            $this->main_table = false;
            // query from multiple tables
        }
        $this->args['table'][] = array($table, $alias);
        return $this;
    }

Usage Example

Exemple #1
0
 function table($table = undefined, $alias = undefined)
 {
     if ($this->prefix && $alias == undefined) {
         $alias = $table;
     }
     return parent::table($this->prefix . $table, $alias);
 }
All Usage Examples Of DB_dsql::table