public function getTablesFromSQL($sql) {
        $p      = '/CREATE\s+TABLE\s+(IF\s+NOT\s+EXISTS\s+)?([^\(]+)/mi';
        $tables = [];
        $views  = [];
        if (preg_match_all($p, $sql, $ms, PREG_SET_ORDER)) {
            foreach ($ms as $m) {
                if (count($m) == 3) {
                    $table = $m [2];
                } else {
                    $table = $m [1];
                }
                if ($table) {
                    $table     = trim(trim($table, '` '));
                    $tables [] = str_replace('{prefix}', $this->tablePrefix, $table);
                }
            }
        }
        $p = '/CREATE\s+VIEW\s+(IF\s+NOT\s+EXISTS\s+)?(.+?)\s+AS/mi';
        if (preg_match_all($p, $sql, $ms, PREG_SET_ORDER)) {
            foreach ($ms as $m) {
                if (count($m) == 3) {
                    $table = $m [2];
                } else {
                    $table = $m [1];
                }
                if ($table) {
                    $table    = trim(trim($table, '` '));
                    $views [] = str_replace('{prefix}', $this->tablePrefix, $table);
                }
            }
        }

        return ['tables' => $tables, 'views' => $views];
    }
public function getTablesFromSQL($sql) {
        $p      = '/CREATE\s+TABLE\s+(IF\s+NOT\s+EXISTS\s+)?([^\(]+)/mi';
        $tables = [];
        $views  = [];
        if (preg_match_all($p, $sql, $ms, PREG_SET_ORDER)) {
            foreach ($ms as $m) {
                if (count($m) == 3) {
                    $table = $m [2];
                } else {
                    $table = $m [1];
                }
                if ($table) {
                    $table     = trim(trim($table, '` '));
                    $tables [] = str_replace('{prefix}', $this->tablePrefix, $table);
                }
            }
        }
        $p = '/CREATE\s+VIEW\s+(IF\s+NOT\s+EXISTS\s+)?(.+?)\s+AS/mi';
        if (preg_match_all($p, $sql, $ms, PREG_SET_ORDER)) {
            foreach ($ms as $m) {
                if (count($m) == 3) {
                    $table = $m [2];
                } else {
                    $table = $m [1];
                }
                if ($table) {
                    $table    = trim(trim($table, '` '));
                    $views [] = str_replace('{prefix}', $this->tablePrefix, $table);
                }
            }
        }

        return ['tables' => $tables, 'views' => $views];
    }
public function getTablesFromSQL ( $ sql ) { $ p = '/CREATE\s+TABLE\s+(IF\s+NOT\s+EXISTS\s+)?([^\(]+)/mi' ; $ tables = [ ] ; $ views = [ ] ; if ( preg_match_all ( $ p , $ sql , $ ms , PREG_SET_ORDER ) ) { foreach ( $ ms as $ m ) { if ( count ( $ m ) == 3 ) { $ table = $ m [ 2 ] ; } else { $ table = $ m [ 1 ] ; } if ( $ table ) { $ table = trim ( trim ( $ table , '` ' ) ) ; $ tables [ ] = str_replace ( '{prefix}' , $ this -> tablePrefix , $ table ) ; } } } $ p = '/CREATE\s+VIEW\s+(IF\s+NOT\s+EXISTS\s+)?(.+?)\s+AS/mi' ; if ( preg_match_all ( $ p , $ sql , $ ms , PREG_SET_ORDER ) ) { foreach ( $ ms as $ m ) { if ( count ( $ m ) == 3 ) { $ table = $ m [ 2 ] ; } else { $ table = $ m [ 1 ] ; } if ( $ table ) { $ table = trim ( trim ( $ table , '` ' ) ) ; $ views [ ] = str_replace ( '{prefix}' , $ this -> tablePrefix , $ table ) ; } } } return [ 'tables' => $ tables , 'views' => $ views ] ; }
get tables from sql.

@param string $sql

@return array array('tables'=>array(),'views'=>array()) name array of tables and views defined in sql.
get tables from sql .