Welcome Guest, Not a member yet? Register   Sign In
Database Forge Issue
#1

[eluser]GamingFusion[/eluser]
Im having a problem using Database Forge to create my databases. Using the user guide i came up with this code
Code:
<?php

class Database extends Model {

    function database() {
        
        parent::Model();
    }
    
    function createTables()
    {
        $this->dbforge->create_table('users', TRUE);
        
        $fields = array(
                        'id' => array('type' => 'int')
);
$this->dbforge->add_column('users', $fields);
        
        //$this->dbforge->create_table('details', TRUE);
    
    }
    
}

?>
and when i load my page i get this
Quote:An Error Was Encountered
Field information is required.

whats wrong?
#2

[eluser]InsiteFX[/eluser]
You can not have 2 Classes with the name CodeIgniter has a dabase class.

Change your class name to something else.

InsiteFX
#3

[eluser]GamingFusion[/eluser]
I updated my code but im still getting the same error.

Model: installDB
Code:
<?php

class InstallDB extends Model {
    
    function installDB()
    {
        parent::Model();
    }
    
    function createTables()
    {
        $this->dbforge->create_table('users', TRUE);
        
        $fields = array(
                        'id' => array('type' => 'int')
);
$this->dbforge->add_column('users', $fields);
        
        //$this->dbforge->create_table('details', TRUE);
    
    }
    
    function insertdetails()
    {
        
    }
    
}

?>

Controller: install
Code:
<?php

class Install extends Controller
{
    function install() {
        
        parent::Controller();
        $this->load->model('installDB');
        $this->load->dbforge();
        
    }

    function index()
    {
        $data['title'] = 'SkyePHP | Install SkyePHP';
        
        $this->installDB->createTables();
        
        $this->load->view('install_view', $data);
    }
    
    function sitedetails() {
            $this->installDB->insertdetails();
    }
    
    function step2() {
        
    }
    
    function step3() {
        
    }
    
}

?>
#4

[eluser]InsiteFX[/eluser]
Try this and see if it will work for you.
Also make sure that the database is loaded or it will not work!

Model: installDB
Code:
<?php

class InstallDB extends Model {
    
    function installDB()
    {
        parent::Model();

        $this->load->dbforge();
    }
    
    function createTables()
    {
        $this->dbforge->create_table('users', TRUE);
        
        $fields = array(
                        'id' => array('type' => 'int')
);
$this->dbforge->add_column('users', $fields);
        
        //$this->dbforge->create_table('details', TRUE);
    
    }
    
    function insertdetails()
    {
        
    }
    
}

?>

Controller: install
Code:
<?php

class Install extends Controller
{
    function install() {
        
        parent::Controller();
        $this->load->model('installDB');
        
    }

    function index()
    {
        $data['title'] = 'SkyePHP | Install SkyePHP';
        
        $this->installDB->createTables();
        
        $this->load->view('install_view', $data);
    }
    
    function sitedetails() {
            $this->installDB->insertdetails();
    }
    
    function step2() {
        
    }
    
    function step3() {
        
    }
    
}

?>

InsiteFX
#5

[eluser]GamingFusion[/eluser]
same error but i get a new one

Quote:A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /Users/GamingFusion/Sites/IonPHP/system/application/models/installdb.php:32)

Filename: codeigniter/Common.php

Line Number: 360
#6

[eluser]Dennis Rasmussen[/eluser]
You have a space after ?>

Just remove ?> as well.
#7

[eluser]GamingFusion[/eluser]
i still have that first error fixed the second one thanks
#8

[eluser]tonanbarbarian[/eluser]
can you provide the exact text of the error
if there is a line number in the error that might be helpful
you would have to indicate which line it is in your code if it does
#9

[eluser]GamingFusion[/eluser]
all it says is this:

An Error Was Encountered
Field information is required.

and it seems to be on this line

Code:
$this->dbforge->create_table('users', TRUE);
#10

[eluser]GamingFusion[/eluser]
-bump-




Theme © iAndrew 2016 - Forum software by © MyBB