View Single Post
Old 11-17-2007, 04:58 PM   #8 (permalink)
Morishani
The Contributor
 
Join Date: Nov 2007
Posts: 32
Thanks: 5
Morishani is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
Inside your table class, just add a member variable which is an instance of the columns class.

For example (only an example!):
PHP Code:
class table
{
    public 
$columns;
    public function 
__construct()
    {
        
$this->columns = new columns();
    }
}

// Then you can do:
$table = new table();
$table->columns->add('asdf'); 
Salath, I think I'm gonna choose your solution to this problem, but now i've got another problem - how to get to the table object from the columns object,
what i did is something like this, and i want to know if it's correct :
PHP Code:
class inner_class
    
{
    private 
$parent;
    function 
__construct($parent)
        {
        
$this->parent $parent;
        }
    public function 
a()
        {
        return 
$this->parent->name;
        }
    }

class 
outer_class
    
{
    public 
$name;
    public 
$iClass;

    function 
__construct()
        {
        
$this->name "asdf";
        
$this->iClass = new inner_class($this);
        }
    }

$a = new outer_class();
echo 
$a->iClass->a(); 
Is it ok to work like that?
Send a message via ICQ to Morishani Send a message via MSN to Morishani
Morishani is offline  
Reply With Quote