public static function getTables($statement)
    {
        $expressions = [];

        if (($statement instanceof InsertStatement)
            || ($statement instanceof ReplaceStatement)
        ) {
            $expressions = [$statement->into->dest];
        } elseif ($statement instanceof UpdateStatement) {
            $expressions = $statement->tables;
        } elseif (($statement instanceof SelectStatement)
            || ($statement instanceof DeleteStatement)
        ) {
            $expressions = $statement->from;
        } elseif (($statement instanceof AlterStatement)
            || ($statement instanceof TruncateStatement)
        ) {
            $expressions = [$statement->table];
        } elseif ($statement instanceof DropStatement) {
            if (! $statement->options->has('TABLE')) {
                // No tables are dropped.
                return [];
            }
            $expressions = $statement->fields;
        } elseif ($statement instanceof RenameStatement) {
            foreach ($statement->renames as $rename) {
                $expressions[] = $rename->old;
            }
        }

        $ret = [];
        foreach ($expressions as $expr) {
            if (! empty($expr->table)) {
                $expr->expr = null; // Force rebuild.
                $expr->alias = null; // Aliases are not required.
                $ret[] = Expression::build($expr);
            }
        }

        return $ret;
    }
public static function getTables($statement)
    {
        $expressions = [];

        if (($statement instanceof InsertStatement)
            || ($statement instanceof ReplaceStatement)
        ) {
            $expressions = [$statement->into->dest];
        } elseif ($statement instanceof UpdateStatement) {
            $expressions = $statement->tables;
        } elseif (($statement instanceof SelectStatement)
            || ($statement instanceof DeleteStatement)
        ) {
            $expressions = $statement->from;
        } elseif (($statement instanceof AlterStatement)
            || ($statement instanceof TruncateStatement)
        ) {
            $expressions = [$statement->table];
        } elseif ($statement instanceof DropStatement) {
            if (! $statement->options->has('TABLE')) {
                // No tables are dropped.
                return [];
            }
            $expressions = $statement->fields;
        } elseif ($statement instanceof RenameStatement) {
            foreach ($statement->renames as $rename) {
                $expressions[] = $rename->old;
            }
        }

        $ret = [];
        foreach ($expressions as $expr) {
            if (! empty($expr->table)) {
                $expr->expr = null; // Force rebuild.
                $expr->alias = null; // Aliases are not required.
                $ret[] = Expression::build($expr);
            }
        }

        return $ret;
    }
public static function getTables ( $ statement ) { $ expressions = [ ] ; if ( ( $ statement instanceof InsertStatement ) || ( $ statement instanceof ReplaceStatement ) ) { $ expressions = [ $ statement -> into -> dest ] ; } elseif ( $ statement instanceof UpdateStatement ) { $ expressions = $ statement -> tables ; } elseif ( ( $ statement instanceof SelectStatement ) || ( $ statement instanceof DeleteStatement ) ) { $ expressions = $ statement -> from ; } elseif ( ( $ statement instanceof AlterStatement ) || ( $ statement instanceof TruncateStatement ) ) { $ expressions = [ $ statement -> table ] ; } elseif ( $ statement instanceof DropStatement ) { if ( ! $ statement -> options -> has ( 'TABLE' ) ) { // No tables are dropped. return [ ] ; } $ expressions = $ statement -> fields ; } elseif ( $ statement instanceof RenameStatement ) { foreach ( $ statement -> renames as $ rename ) { $ expressions [ ] = $ rename -> old ; } } $ ret = [ ] ; foreach ( $ expressions as $ expr ) { if ( ! empty ( $ expr -> table ) ) { $ expr -> expr = null ; // Force rebuild. $ expr -> alias = null ; // Aliases are not required. $ ret [ ] = Expression :: build ( $ expr ) ; } } return $ ret ; }
Gets a list of all tables used in this statement.

@param Statement $statement statement to be scanned

@return array
Gets a list of all tables used in this statement .