Welcome Guest, Not a member yet? Register   Sign In
CI in library object
#1

[eluser]Joozt[/eluser]
I got a superclass in witch use the CI to get a database connection.

Code:
abstract class Superclass{
    
    protected $data = array();
    protected $CI;
    
    function Superclass(){
        $this->CI = & get_instance();
        $this->CI->load->database();
    }

Now I cot a client class witch extends superclass

Code:
class Client extends Superclass
{
    var $ClientID;
    var $Invoice_AddressID;
    var $Posting_AddressID;
    var $Visiting_AddressID;

    public $data = array();
    
    
    function Client($client = null)
    {
           parent::Superclass();

When I make an object of client and print it i get the following:
Client Object
(
[ClientID] => 13
[Invoice_AddressID] => 1
[Posting_AddressID] => 2
[Visiting_AddressID] => 3
[data] => Array
(
[ClientID] => 13
[Invoice_AddressID] => 1
[Posting_AddressID] => 2
[Visiting_AddressID] => 3
[CountryID] => 31
[Company_Name] => test insert
[TypeID] => 1
[Phone] =>
[Fax] =>
[Email] =>
[Website] =>
[Company_Number] =>
[IBAN] =>
[VAT] =>
[Info] =>
[Payment_Term] => 30
)

[CI:protected] => Facturen Object
(
[_ci_scaffolding] =>
[_ci_scaff_table] =>
[config] => CI_Config Object
(
[config] => Array
(
[base_url] => http://cashgo/
[index_page] =>
[uri_protocol] => AUTO
[url_suffix] =>
[language] => english
[charset] => UTF-8
[enable_hooks] =>
[subclass_prefix] => MY_
[permitted_uri_chars] => a-z 0-9~%.:_-
[enable_query_strings] =>
[controller_trigger] => c
[function_trigger] => m
[log_threshold] => 0

ect...


I don't really want the [CI:protected] in my object, atleast not when I print the object with print_r

Does anyone know how I should define $CI so that i can use it in the client class, but in a way that it isn't shown with print_r of the client object?


Thanks alot in advance for the replies.



Is there a way wher
#2

[eluser]wiredesignz[/eluser]
Don't make $CI a class variable. Use it discreetly in the functions that need it.

Code:
abstract class Superclass
{
    protected $data = array();
    
    function Superclass()
    {
        $CI = &get;_instance();
        $CI->load->database();
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB