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.
#2

[eluser]TheFuzzy0ne[/eluser]
You're controller IS the CodeIgniter Super Object. Try $this->CI->load->database(); instead. Also, your class name and constructor should have the first character in uppercase. This is not the cause of you problem, but it is the recommended way to do things.
#3

[eluser]jkarlen[/eluser]
Wow. I was totally looking at the wrong problem. Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB