View Single Post
Old 08-02-2008, 07:16 PM   #1 (permalink)
Aaron
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 378
Thanks: 45
Aaron is on a distinguished road
Default Is this OO Possible? (Method Chaining)

PHP Code:
class MyClass
{
  public function 
instSql()
  {
    
$sql = new Sql;
  }
}
class 
Sql
{
  private function 
Sql() // Constructor
  
{
    
// Connect to the database, blah blah blah
    
return $this;
  }

  public function 
Query()
  {
    
// Send a query
    
return $result;
  }
}


// Later...

$cl = new MyClass;
$cl->instSql->Query(); 
Uhh... That kind of got confusing... Anyway, would something like this work?
__________________
Signatures are nothing but incriminating.
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote