public function copyTableData( $from, $to, $columns )
    {
        // get existing rows
        $cols = implode( ', ', array_keys( $columns ) );
        $cols = rtrim( $cols, ',' );

        // move all data to new table
        $rows = $this->query( "SELECT $cols FROM $to" );

        foreach ( $rows as $row )
        {
            $query = "INSERT INTO $from ( $cols ) VALUES ( " .
                rtrim( str_repeat( '?,', count( $columns ), ',' ) ) .
                " )";

            $values = [ ];

            foreach ( $row as $key => $value )
            {
                if ( in_array( $key, array_keys( $columns ) ) )
                {
                    $values[ ] = $row[ $key ];
                }
            }

            $this->execute( $query, $values );
        }
    }
public function copyTableData( $from, $to, $columns )
    {
        // get existing rows
        $cols = implode( ', ', array_keys( $columns ) );
        $cols = rtrim( $cols, ',' );

        // move all data to new table
        $rows = $this->query( "SELECT $cols FROM $to" );

        foreach ( $rows as $row )
        {
            $query = "INSERT INTO $from ( $cols ) VALUES ( " .
                rtrim( str_repeat( '?,', count( $columns ), ',' ) ) .
                " )";

            $values = [ ];

            foreach ( $row as $key => $value )
            {
                if ( in_array( $key, array_keys( $columns ) ) )
                {
                    $values[ ] = $row[ $key ];
                }
            }

            $this->execute( $query, $values );
        }
    }
public function copyTableData ( $ from , $ to , $ columns ) { // get existing rows
 $ cols = implode ( ', ' , array_keys ( $ columns ) ) ; $ cols = rtrim ( $ cols , ',' ) ; // move all data to new table
 $ rows = $ this -> query ( "SELECT $cols FROM $to" ) ; foreach ( $ rows as $ row ) { $ query = "INSERT INTO $from ( $cols ) VALUES ( " . rtrim ( str_repeat ( '?,' , count ( $ columns ) , ',' ) ) . " )" ; $ values = [ ] ; foreach ( $ row as $ key => $ value ) { if ( in_array ( $ key , array_keys ( $ columns ) ) ) { $ values [ ] = $ row [ $ key ] ; } } $ this -> execute ( $ query , $ values ) ; } }
Copy table data from one table to another.

@param string $from
@param string $to
@param array  $columns
Copy table data from one table to another .