public function addTable($table, $after=null) {

        // Calculate the previous and next tables
        $prevtable = null;
        $nexttable = null;

        if (!$after) {
            if ($this->tables) {
                end($this->tables);
                $prevtable = $this->tables[key($this->tables)];
            }
        } else {
            $prevtable = $this->getTable($after);
        }
        if ($prevtable && $prevtable->getNext()) {
            $nexttable = $this->getTable($prevtable->getNext());
        }

        // Set current table previous and next attributes
        if ($prevtable) {
            $table->setPrevious($prevtable->getName());
            $prevtable->setNext($table->getName());
        }
        if ($nexttable) {
            $table->setNext($nexttable->getName());
            $nexttable->setPrevious($table->getName());
        }
        // Some more attributes
        $table->setLoaded(true);
        $table->setChanged(true);
        // Add the new table
        $this->tables[] = $table;
        // Reorder the whole structure
        $this->orderTables($this->tables);
        // Recalculate the hash
        $this->calculateHash(true);
        // We have one new table, so the structure has changed
        $this->setVersion(userdate(time(), '%Y%m%d', 99, false));
        $this->setChanged(true);
    }
public function addTable($table, $after=null) {

        // Calculate the previous and next tables
        $prevtable = null;
        $nexttable = null;

        if (!$after) {
            if ($this->tables) {
                end($this->tables);
                $prevtable = $this->tables[key($this->tables)];
            }
        } else {
            $prevtable = $this->getTable($after);
        }
        if ($prevtable && $prevtable->getNext()) {
            $nexttable = $this->getTable($prevtable->getNext());
        }

        // Set current table previous and next attributes
        if ($prevtable) {
            $table->setPrevious($prevtable->getName());
            $prevtable->setNext($table->getName());
        }
        if ($nexttable) {
            $table->setNext($nexttable->getName());
            $nexttable->setPrevious($table->getName());
        }
        // Some more attributes
        $table->setLoaded(true);
        $table->setChanged(true);
        // Add the new table
        $this->tables[] = $table;
        // Reorder the whole structure
        $this->orderTables($this->tables);
        // Recalculate the hash
        $this->calculateHash(true);
        // We have one new table, so the structure has changed
        $this->setVersion(userdate(time(), '%Y%m%d', 99, false));
        $this->setChanged(true);
    }
public function addTable ( $ table , $ after = null ) { // Calculate the previous and next tables $ prevtable = null ; $ nexttable = null ; if ( ! $ after ) { if ( $ this -> tables ) { end ( $ this -> tables ) ; $ prevtable = $ this -> tables [ key ( $ this -> tables ) ] ; } } else { $ prevtable = $ this -> getTable ( $ after ) ; } if ( $ prevtable && $ prevtable -> getNext ( ) ) { $ nexttable = $ this -> getTable ( $ prevtable -> getNext ( ) ) ; } // Set current table previous and next attributes if ( $ prevtable ) { $ table -> setPrevious ( $ prevtable -> getName ( ) ) ; $ prevtable -> setNext ( $ table -> getName ( ) ) ; } if ( $ nexttable ) { $ table -> setNext ( $ nexttable -> getName ( ) ) ; $ nexttable -> setPrevious ( $ table -> getName ( ) ) ; } // Some more attributes $ table -> setLoaded ( true ) ; $ table -> setChanged ( true ) ; // Add the new table $ this -> tables [ ] = $ table ; // Reorder the whole structure $ this -> orderTables ( $ this -> tables ) ; // Recalculate the hash $ this -> calculateHash ( true ) ; // We have one new table, so the structure has changed $ this -> setVersion ( userdate ( time ( ) , '%Y%m%d' , 99 , false ) ) ; $ this -> setChanged ( true ) ; }
Add one table to the structure, allowing to specify the desired order
If it's not specified, then the table is added at the end.
@param xmldb_table $table
@param mixed $after
Add one table to the structure allowing to specify the desired order If it s not specified then the table is added at the end .