Welcome Guest, Not a member yet? Register   Sign In
DBForge or SQL Schema import
#1

[eluser]spyro[/eluser]
I have three questions.

1. The first is which do you recommend to use in an installer, to build tables with DBForge or use a schema dump? Schema dump seems easier unless you can add to the reasoning that it is not.

2. If are using a schema dump from phpmyadmin then how do you import without errors?

I read the file into a string, did the escape sequence, and ran the query and got errors on a dump that I know will import from the CLI.

3. Using dbforge I keep getting this error:

A PHP Error was encountered

Severity: Notice

Message: Array to string conversion

Filename: database/DB_driver.php

Line Number: 1206

Not sure where it is trying to convert using the code below:
Code:
$this->load->dbforge();
        
        $fields = array(
                        'id' => array(
                                                 'type' => 'INT',
                                                 'constraint' => 10,
                                                 'auto_increment' => TRUE
                                          ),
                        'instance_1' => array(
                                                 'type' => 'INT',
                                                 'constraint' => '10',
                                          ),
                        'snapshot_1' => array(
                                                 'type' =>'INT',
                                                 'constraint' => '10',
                                          ),
                        'instance_2' => array(
                                                 'type' => 'INT',
                                                 'contraint' => '10',
                                          ),
                        'snapshot_2' => array(
                                                 'type' => 'INT',
                                                 'contraint' => '10',
                                          ),
                );
        
        $this->dbforge->add_field($fields);
        $this->dbforge->add_key('id', TRUE);
        $this->dbforge->create_table('comparisons');
#2

[eluser]TheFuzzy0ne[/eluser]
Hmm... Beats me. What version of CodeIgniter are you using? Have you tried omitting the call to "create_table" and building your array one line at a time. See if you can pin-point the problem.
#3

[eluser]spyro[/eluser]
Version 1.7.1. I was hoping to get input on which route would be best and why before I got to deep into either.
#4

[eluser]TheFuzzy0ne[/eluser]
I think this needs to be reported as a bug. Even the example in the user guide doesn't work... I will see if I can figure out a fix later tonight.

EDIT: Just using a database dump is faster than using dbforge. I'd only recommend using dbforge if you need to create something like table/field names dynamically, or need some other logic that a simple database dump cannot handle.
#5

[eluser]WanWizard[/eluser]
Remember that using a schema dump (most likely) ties you to a particular database engine.

dbforge is compatible across engines, so if you need portability, go for dbforge. Speed is not an issue anywhere, we are talking about once-in-a-blue-moon setup code...

(p.s. I don't seem to be able to reproduce the notice...)




Theme © iAndrew 2016 - Forum software by © MyBB