Welcome Guest, Not a member yet? Register   Sign In
Developing with SVN and CI - best practices?
#7

[eluser]Jonas G[/eluser]
I like the idea about working on an online test database - i'll do that for my next project. If you like the idea about working offline (as I do), here's my method:

What I do now is dump the database to an .sql file and then have a controller which imports the sql file:

Code:
$sql_file = APPPATH.'sql/dump_all.sql';
                echo 'This might take some time...';
                $handle = @fopen($sql_file, "r");
                $query = "";
                while(!feof($handle)) {
                    $sql_line = fgets($handle);
                    if (trim($sql_line) != "" && strpos($sql_line, "--") === false) {
                        $query .= $sql_line;
                        if (preg_match("/;[\040]*\$/", $sql_line)) {
                            $this->db->query($query);
                            $query = "";
                        }
                    }
                }
                echo 'Done...';

That way you can add the .sql file to the repo and when there is updates to the database just run a local URL which calls the above.

I use this with mysql dumps but would be much more versatile if it used ALTER TABLE and the like... Be careful about this way though - there's no reverting.


Messages In This Thread
Developing with SVN and CI - best practices? - by El Forum - 11-15-2007, 08:23 PM
Developing with SVN and CI - best practices? - by El Forum - 11-16-2007, 07:42 AM
Developing with SVN and CI - best practices? - by El Forum - 11-16-2007, 03:19 PM
Developing with SVN and CI - best practices? - by El Forum - 11-17-2007, 03:14 AM
Developing with SVN and CI - best practices? - by El Forum - 11-17-2007, 06:44 PM
Developing with SVN and CI - best practices? - by El Forum - 02-21-2009, 11:58 AM
Developing with SVN and CI - best practices? - by El Forum - 02-22-2009, 12:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB