Welcome Guest, Not a member yet? Register   Sign In
DBForge->add_column Failing
#1

[eluser]whobutsb[/eluser]
Hello All,

I'm working a on a method that allow me to create additional fields in a database if they don't already exist in the database.

Here is the method I wrote:
Code:
$this->load->dbforge();
foreach($fields as $field){
            
            //Check to see if each exists in the database
            if(!$this->db->field_exists($field, $tableName)){
            
                //Add the column if it doesn't exist
                $column = array(
                    $field    =>    array(
                        'type'            => 'VARCHAR',
                        'constraint'    => '255',
                        'NULL'            => TRUE
                    )
                );
                
                $this->dbforge->add_column($tableName, $column);
            }
        }

The problem is when I run this I get this output:

Error Number:
ALTER TABLE _tblDis_MyTestGuestsLis ADD Array NOT NULL

It looks like the DBforge is not taking apart the array I wrote and is just outputting the array. Maybe i'm missing something with all of this? BTW I'm using MSSQL, would that have something to do with it?

Thanks for help!

steve
#2

[eluser]gtech[/eluser]
hi steve,

I searched the forums for you and found this post
[url="http://ellislab.com/forums/viewthread/76151/"]thread 76151[/url] check out seppo's reply, he has the identical error you have.

looks like this works in mysql.. the problem was fixed for the mysqli driver as a result of the thread... don't know if this helps you at all, but it could be a bug in the driver code.

cheers
#3

[eluser]whobutsb[/eluser]
Thanks for the help! I probably just need to copy some of the MYSQL DBForge methods into my MSSQL DBForge add_column methods to get this to work.
#4

[eluser]gtech[/eluser]
yeah sounds like it.. might be worth logging a bug if you get anywhere with it.
#5

[eluser]Unknown[/eluser]
[quote author="whobutsb" date="1245075791"]Thanks for the help! I probably just need to copy some of the MYSQL DBForge methods into my MSSQL DBForge add_column methods to get this to work.[/quote]

Hey whobutsb, may I know what I need to copy from MYSQL DBForge methods to MSSQL DBForge add_column methods?

Thank you.




Theme © iAndrew 2016 - Forum software by © MyBB