Welcome Guest, Not a member yet? Register   Sign In
Help with library
#1

[eluser]jkarlen[/eluser]
I am writing a library and trying to gain access to the CI super class through get_instance() but get_instance is returning a reference to the controller rather than to the CI superclass.

This is my controller:

<?php

class test extends Controller
{

function test()
{
parent::Controller();
}

function index()
{
$this->load->library('session');


$this->session->set_userdata( array('name' => 'jon') );
$this->load->library('WorkroomOrder', array('id' => 7370786));
}
}
?>

This is my library:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');


class WorkroomOrder
{
var $CI;


var $order_id;
var $order_segment;


function WorkroomOrder( $params )
{
$this->CI =& get_instance();
$this->CI->load('database');

$query = $this->CI->db->query_where('orders', array('id' => $params['id']));

$order = $query->row();
}

function get_address( $type = 'shipping' )
{


}
}
?>

The $this->CI->load(‘database’) call fails with the error that test::load() is undefined so it definitely seems that get_instance() is returning a reference to my controller and not the CI superclass.


Messages In This Thread
Help with library - by El Forum - 06-24-2009, 07:47 AM
Help with library - by El Forum - 06-24-2009, 08:20 AM
Help with library - by El Forum - 06-24-2009, 08:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB