Welcome Guest, Not a member yet? Register   Sign In
Library class loaded, but I can't access it from a model??
#1

[eluser]nikefido[/eluser]
Code within my model:

Code:
<?php
class Loginmodel extends Model {
    
    private $user;
    
    public function Loginmodel() {
        parent::Model();
        $this->load->library('Factory');
        $this->factory->getUser('DS_Admin');
    }    
}

My library object:
Code:
<?php

class Factory {

    public function __construct() {
        //nothing
        echo 'yay';
    }

    private function __autoload($classname) {
        require_once('system/application/libraries/DS/'.$classname.'php');
    }
    
    public function getUser($usertype) {
        switch ($usertype) {
            case 'DS_Admin' :
                return new DS_Admin;
            case 'DS_Broker' :
                return new DS_Broker;
            case 'DS_MasterBroker' :
                return new DS_MasterBroker;
            default :
                return false;
        }
    }
}

Now, the "yay" within my Factory constructor is getting outputted, so I know the library is being loaded.

However, when I attempt to access the "getUser()" function, I receive this error:

Fatal error: Call to a member function getUser() on a non-object in C:\wamp\www\broker\system\application\models\loginmodel.php on line 9


ergh - what am I missing??


Messages In This Thread
Library class loaded, but I can't access it from a model?? - by El Forum - 01-05-2009, 11:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB