Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Class Chaining / Class Inheritance
Old 11-25-2010, 10:06 PM Class Chaining / Class Inheritance - Resolved
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
Okay, folks I am working on private / personal project. It involves the use of IPBWI (Which is a web integration for IPBoard and a website that is using the codeigniter framework for the heavy lifting.

My problem is first of IPBWI and CodeIgniter don't play along in the method that I need them to. As such I have two options. Use IPBWI on each php code page that I need it on (which is a lot, and it will be called several times as it is unable to pass class to class, page to page, etc). The other is to create an 'interface' class/library that I can use directly with CodeIgniter so I can use the pre-built systems of handling a typical class.

What I am running into an issue creating the interface library/class. What I am trying to do is general Class Inheritance. In the main class ips_conversion I define the 'sub classes' that match to the IPBWI. This way I can use the following in any of my other pages

PHP Code:
$this->ips_conversion->members->login($params
Which would translate to

Class :: ips_conversion
Sub Class :: members
Function :: login

I am trying to get it so I can call the main class, and in that method call the sub class with the required function.

Current setup example
PHP Code:
class Ips_conversion{
    
/*
    Function __construct() details
    Loads all 'child' classes    
    */
    
public $member// Members Child Class
    
function __construct(){    
        
$this->CI =& get_instance(); 
        
$this->member = new member($this);
    }
}
class 
member extends Ips_conversion{
    function 
__construct(){
        include(
"/home/me2legion/public_html/includes/ips_sdk/ipbwi.inc.php");
        
$this->IPS = new ipbwi();
    }
    function 
login($usr$pwd$cookie true$anon false){
        
$UID $this->name2id($usr);
        if(
$this->IPS->member->login($UID,$pwd,$cookie,$anon,$usr,$pwd) == TRUE){
            return 
TRUE;
        }
        else{
            return 
FALSE;
        }
    }
    function 
logout(){
        if(
$this->IPS->member->logout() == TRUE){
            return 
TRUE;
        }
        else{
            return 
FALSE;
        }
    }
    function 
name2id($name,$array false){
        if(
$array == false){
            return 
$this->IPS->member->name2id($name);
        }
        else{
            return 
$this->IPS->member->name2id($array);
        }
    }
    function 
isLoggedIn($uid false){
        return 
$this->IPS->member->isLoggedIn($uid);
    }
    function 
isAdmin($uid false){
        return 
$this->IPS->member->isAdmin($uid);
    }
    function 
info($uid false){
        return 
$this->IPS->member->info($uid);
    }
    

In my browser I get the following
Code:
Fatal error: Call to a member function isLoggedIn() on a non-object
Using the following line to call it
PHP Code:
$this->Ips_conversion->member->isLoggedIn(); 
TIA Jon
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1

Last edited by amw_drizz; 11-26-2010 at 12:26 PM.. Reason: resolved
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
 
Register now for full access!
Old 11-26-2010, 11:22 AM Re: Class Chaining / Class Inheritance
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
Thanks for looking but I got it.

My problem was that I was creating a class to use directly inside of CI, whereas I should of created a class in one of CI's helper files. Doing that solved my problem, since I don't need any CI functions inside of my interface class to IPBWI.
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Reply     « Reply to Class Chaining / Class Inheritance
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14081 seconds with 12 queries