Here's a link to a series of 4 articles that explain aggregation in
PHP.....as this sounds like what you want to do.

http://www.devshed.com/c/a/PHP/Object-Interaction-in-PHP-Introduction-to-Aggregation-part-1/

HTH
Steve
"Graham Anderson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> What is the correct syntax for calling methods from other  classes  into
> your own class ?
>
>
> Example:
> Calling the ADODB class with:
> $this->conn=&ADONewConnection('mysql');
>
>
> This works:
> $rs= $this->conn->GetAll("SELECT title FROM content WHERE page_id= ?",
> $id);
>
> This fails:
> while (!$rs->$this->conn->EOF)
> {
> // iterate through $rs
> }
>
>
> Can someone point me in the right direction ?
> I did not want to use 'Extends' because I wanted incorporate several
> pre-existing classes,like ADODB,  into my own class
> I am more than a bit new at OOP so any help is appreciated.
>
>
> Code:
> <?php
> require ("./adodb/adodb.inc.php");
>
> $PageBuilder = new PageBuilder();
> $PageBuilder->getPageTextbyID($id=1);
>
> //------------------------------------------------------
>
> class PageBuilder{
>
> public function __construct() {
> $this->connect2db('localhost','u','p','db');
> }
>
>
> public function __destruct() {
> # Close the db connection
> $this->conn->Close();
> }
>
>
>
> //---- Methods within the PageBuilder Class ---- //
>
> private function connect2db()
> {
> $this->conn=&ADONewConnection('mysql');
> $this->conn->Connect($server,$u,$p,$db); }
>
>
> public function getPageTextbyID($id)
> {
> // this query DOES work
> $rs= $this->conn->GetAll("SELECT title FROM content WHERE page_id= ?",
> $id);
>
>
> // ---------------Now iterate through $rs----------------//
>
> // Original Iteration Code
>
> while (!$rs->EOF) {
> for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++)
> print $result->fields[$i].' ';
> $rs->MoveNext();
> print "<br>\n";
>
>
> //    Failed: First Attempt using $this->
>
> while (!$rs->$this->conn->EOF)
> {
> for ($i=0, $max=$rs->$this->conn->FieldCount(); $i < $max; $i++)
> echo "the result is:". $rs->$this->conn->fields[$i].' ';
> $rs->$this->conn->MoveNext();
> print "<br>\n";
> }
>
>
> // Failed: Second Attempt using ::
>
> while (!$rs->conn::EOF)
> {
> for ($i=0, $max=$rs->conn::FieldCount(); $i < $max; $i++)
> echo  $rs->conn::fields[$i].' ';
> $rs->conn::MoveNext();
> print "<br>\n";
> }
>
>
> }

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to