Welcome Guest, Not a member yet? Register   Sign In
CI 3 - Migration Error
#1

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Migration::$migration

Filename: admin/Migration.php

Line Number: 16

Backtrace:

File: C:\codeigniter_blog\application\controllers\admin\Migration.php
Line: 16
Function: _error_handler

File: C:\wamp\www\blog\index.php
Line: 306
Function: require_once


Code:
A PHP Error was encountered

Severity: Error

Message: Call to a member function current() on a non-object

Filename: admin/Migration.php

Line Number: 16

Backtrace:

PHP Code:
Migration.php

class Migration extends Admin_Controller {
 
   public function __construct() {
 
       parent::__construct();
 
   }

 
   public function index() {
 
       $this->load->library('migration');
 
       if ($this->migration->current() === FALSE) {
 
           show_error($this->migration->error_string());
 
       }
 
       else {
 
           echo "Migration Success";
 
       }
 
   }


PHP Code:
20150105121212_create_users.php

defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Migration_Create_users extends CI_Migration {

 
   public function up()
 
   {
 
       $this->dbforge->add_field(array(
 
           'id' => array(
 
               'type' => 'INT',
 
               'constraint' => 11,
 
               'unsigned' => TRUE,
 
               'auto_increment' => TRUE
            
),
 
           'email' => array(
 
               'type' => 'VARCHAR',
 
               'constraint' => '100',
 
           ),
 
           'password' => array(
 
               'type' => 'VARCHAR',
 
               'constraint' => '128',
 
           ),
 
           'name' => array(
 
               'type' => 'VARCHAR',
 
               'constraint' => '100',
 
           ),
 
       ));
 
       $this->dbforge->add_key('id'TRUE);
 
       $this->dbforge->create_table('users');
 
   }

 
   public function down()
 
   {
 
       $this->dbforge->drop_table('users');
 
   }


Why am i getting this error?
Reply
#2

(This post was last modified: 01-05-2015, 03:18 AM by ivantcholakov. Edit Reason: Name suggestion )

I think, if you rename the controller class not to be Migration the error will disappear.

Edit: Migrate
Reply
#3

(01-05-2015, 03:17 AM)ivantcholakov Wrote: I think, if you rename the controller class not to be Migration the error will disappear.

Edit: Migrate

Thanks. It worked!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB