Welcome Guest, Not a member yet? Register   Sign In
sub functions in class
#1

[eluser]Guntars[/eluser]
Hi,
I have a problem with functions in classes

here is an example
Code:
class Admin extends Controller {
var $admin;
var $id;

    function Admin()
    {
        
        parent::Controller();
        
    
    }
function someffunction(){
function subfunction(){
$result=$this->db->get('articles');
$result=$result->result();
return $result;

}

$newresult=$this->somefunction()->subfunction();
print_r($newresult);
}

become as error, I try to find in here and in google, but can't really find if possible to get sub functions with data.

I know have nice thing &get;_instance, but my question if it's possible to get without this.
#2

[eluser]Dam1an[/eluser]
Sorry, I'm not quite sure what you're trying to acheive here, and why you'd want a funtion in a function?
Also, you should really move the db calls to a model Smile
#3

[eluser]Guntars[/eluser]
Just an Idea is, In my CMS website have a plugins facility, and I want to live these separately from root code. In general everything it's fine, but some times I need some extra function. I can solve this If I use &get;_instance. and all data loads fine, but I not really like this method.

I'm not sure if you understand what I mean, but the main question is, if it's possible to get function from function with $this method.

I know this need very few times.
#4

[eluser]SpooF[/eluser]
You might be able to do that if your somefunction returned an object of a class, but you wouldn't be able to write your functions like that.
#5

[eluser]Jondolar[/eluser]
Functions that are not part of a class are global. PHP does not allow a class definition to expand across files. I don't think you can do what you want.




Theme © iAndrew 2016 - Forum software by © MyBB