• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use CI super-global in the new migration library (available in the develop branch of GitHub)

#1
[eluser]Stolz[/eluser]
Hi,

I'm trying to use the Migration library available in the develop branch of GitHub. I've set everything and my migration files are executed, but when I try to run a query in the migration file I get the error

Code:
Call to a member function query() on a non-object in...

My controller
Code:
$this->load->library('migration');
if( ! $this->migration->version(1))
   echo $this->migration->error;

Content of 001_Testing.php file
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Migration_Testing{

function up()
{
  $this->db->query('CREATE TABLE IF NOT EXISTS testings_migrations (some_column int(5) NULL)');
}

  function down()
{
  $this->db->query('DROP TABLE IF EXISTS testings_migrations');
}
}

How can I access the CI super-global object inside the migration files?. I've already tried with the usual $CI =& get_instance(); but no luck.


EDIT

Nevermind, I figure it out. Migration_Testing class needs to extend CI_Migration.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.