Question PEAR::DB , Smarty, OOP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

Question PEAR::DB , Smarty, OOP

Post by harsha »

Code: Select all

<?php
class smartyDB{

	var $ooContainer;
	var $ooResult;
	var $ooRow;

	function smartyDB(){
		$this->Container = array();
        $this->ooResult = NULL;
        $this->ooRow = NULL;
	}
	
	function getMatrix($Sql, $dbHndl){
		$this->ooResult = $dbHndl->query($Sql);
		while($this->ooRow = $this->ooResult->fetchRow(DB_FETCHMODE_ASSOC)){
			array_push($this->ooContainer, $this->ooRow);		
		}
	}
	
	function setMatrix($Name, $smartyObj){
		$smartyObj->assign($Name, $this->ooContainer);
	}
}
?>
I want to do something like, mentioned above with out using include "DB.php" or "smarty.class.php", how do I do that? The above raw method is okay?

It is like, I have included

smarty.class.php
DB.php

in /Index.php

and the above code is in /classlib/smartydb.php

is it possible that one child class extends two parent or base classes?
some thing like


smarty extends DB and also extends Smarty :D :?: :?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

afaik "multiple inheritance" is not supported by php(4|5)

you could emulate it through aggregation

http://www.sitepoint.com/article/dual-i ... lasses-php
Post Reply