CodeIgniter Forums
Best way to insert specific data from Existing Table into newly Created Table... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Best way to insert specific data from Existing Table into newly Created Table... (/showthread.php?tid=40697)



Best way to insert specific data from Existing Table into newly Created Table... - El Forum - 04-15-2011

[eluser]BoyBlue[/eluser]
Ok, so I'm officially feeling defeated with the current way I'm trying to insert specific data from an existing table into a newly created table...

(And, I've been getting AMAZING help from this forum in trying to solve it [InsiteFX you are a total stud for trying to save a flatlined summer-student!]; but I think I've screwed something up so badly that it's probably best for me to admit defeat and start over from scratch)


Here is my current "problem-code" in the Model for trying to insert specific data from an existing table("games") into a newly created table("$table_name"):
Code:
function get_game_data($table_name)
    {

        $this->db->select('game_id, base_number');//Table item(s)
        
        $game_data = $this->db->get('games');//name of table in database

        if ($game_data->num_rows > 0)
        {

        $this->db->select('game_id, base_number');//Table item(s)
        
        $this->db->insert($table_name, $game_data);//name of table in database and items to insert

        }
Can someone please point me in the right direction regarding the best markup you've found for inserting specific data from an existing table into a newly created table with no data in it.

thanks


Best way to insert specific data from Existing Table into newly Created Table... - El Forum - 04-15-2011

[eluser]InsiteFX[/eluser]
@BoyBlue

One other think that I was thinking about is it is possible that your data from the first table is not matching up to the data with your second table.

When doing something like what you are trying to do the data has to match both tables.

InsiteFX


Best way to insert specific data from Existing Table into newly Created Table... - El Forum - 04-15-2011

[eluser]toopay[/eluser]
How your database structure(and tables) looks like?


Best way to insert specific data from Existing Table into newly Created Table... - El Forum - 04-16-2011

[eluser]InsiteFX[/eluser]
@toopay

I had him list the tables in his other post, this is a new post from him.

InsiteFX