Welcome Guest, Not a member yet? Register   Sign In
[SOLVED]CI dbforge help
#1

[eluser]Neocrypter[/eluser]
Hello all im trying to create a simple schema with dbforge but im not sure if im just not using it right or if there is something else wrong here here is my code,
Code:
if($this->db->table_exists('banned_users')){
            echo 'Table banned_users exists, no need to setup.';
        }else{
                $feilds = array(
                            'banned_user_id'=> array(
                                            'type' =>'INT',
                                            'constraint' =>10,
                                            'unsigned'=>TRUE,
                                            'auto_increment'=>TRUE
                        
                            ),
                            'banned_user_slname' => array(
                                                    'type' =>'VARCHAR',
                                                    'constraint'=>100
                            ),
                            'banned_uuid'=>array(
                                            'type'=>'VARCHAR',
                                            'constraint'=>100,                                            
                            ),
                            'banned_from'=>array(
                                            'type'=>'VARCHAR',
                                            'constraint'=>100
                            ),
                            'banned_by'=>array(
                                            'type'=>'VARCHAR',
                                            'constraint'=>60
                            ),
                            'banned_reason'=>array(
                                                'type'=>'VARCHAR',
                                                'constraint'=>500
                            ),
                            'banned_when'=>array(
                                            'type'=>'VARCHAR',
                                            'constraint'=>20
                            )
                                    
            );
            $this->dbforge->add_feild($feilds);
            $this->dbforge->add_field('id');
            $this->dbforge->add_key('banned_user_id',TRUE);
            $this->dbforge->create_table('banned_users',TRUE);
        }

any help would be great thanks
#2

[eluser]Neocrypter[/eluser]
I noticed i had a typo with "field" in the above post, fixed it still getting the same error.
here is the error im getting
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Set_up::$dbforge

Filename: controllers/set_up.php

Line Number: 57


Fatal error: Call to a member function add_field() on a non-object in C:\Users\Public\xampplite\htdocs\gorilla\application\controllers\set_up.php on line 57
#3

[eluser]mi6crazyheart[/eluser]
Have u load the forge class...
Code:
$this->load->dbforge()
#4

[eluser]Neocrypter[/eluser]
yes heres all my loaders I have active in this controller

Code:
function Setup(){
        parent::Controller;
        $this->load->helper('form');
        $this->load->db();
        $this->load->dbforge();            
    }

Dont think it should make a difference as everything else works just fine but i did move the applications folder outside of the system folder
#5

[eluser]WanWizard[/eluser]
Your controller is called 'set_up', but your constructor 'setup'? Don't think that is going to work...
And shouldn't it be
Code:
parent:Controller();
#6

[eluser]Neocrypter[/eluser]
Good catch on that, thanks, everything seems to be working now Big Grin just need to tinker with dbforge a bit now to get past some of the errors im getting with my schema.

one other quick question,
I have a form on another site that I would like to submit data to my CI site, will the input class work with that or will i need to use $_POST, I know it seems impracticable but it is a necessity
#7

[eluser]WanWizard[/eluser]
For your site that is just another post, it doesn't matter that the form came from another site.

Note that this makes you vulnerable to CSRF (for which you should have protected your posts), take that into account. CI 2 will have CSRF protection as standard, so you might want to look into that if you don't want to run into trouble after an upgrade.
#8

[eluser]Neocrypter[/eluser]
Thanks again, the reason I asked is I tried it last night and it wasn't accepting the post data from the external source, but the form I made local which was identical to the foreign form worked just fine, looks like ill have to dig in a little deeper, hadn't realized ci 2 was coming up, so ill have to do some digging on that too. To be honest I haven't done any php work in about 8 years so im playing catch up all over the board, I am glad though I stumbled along the CI framework it has some great time saving features somthing that would have probably taken me a month to do especially catching up with php 5 and mysql 5 looks like its only going to take me a week maybe 2.
#9

[eluser]WanWizard[/eluser]
A post is nothing more than a request of a URL (the form action), and some data passed to the server in the HTTP header. The server, nor CI, cares where the post originated from.

If the post from the external site doesn't work, maybe your missing some information, or the code contains extra checks that fail? Time for some debugging...




Theme © iAndrew 2016 - Forum software by © MyBB