parent::FunctionName()
You still reference functions in the current class using $this->, that way you can have functions of the same name in both classes.
On Jan 20, 2005, at 9:17 PM, Phillip S. Baker wrote:
Greetings all,
I have a class I use for MySQL connection and functions.
I also have a class that I use to create Paged Results.
The paged results class connects to a DB and uses allot of sql calls to make
this happen. I am noticing that it does allot that the MySQL class does.
What I would like to do is to Have the paged results extend the MySQL class
so it can use the functions within that class so I can keep them updated in
just one place. How would I go about doing that?? Is it as simple as
something like this (this is shortened for convience)??
class Mysql { var $results; var $dbcnx;
function Mysql($query, $cnx) { // Constructor function
$this->dbcnx = $cnx;
if (!$this->results = @mysql_query($query))
$this->_error("There was an error with executing your query. Try again
later.", $query);
}
}
class PageResultSet extends MySQL { var $results;
function PageResultSet ($query,$pageSize,$resultpage,$cnx) {
$this->results = @mysql_query($query,$cnx) or $this->_error('Error Running
your search. Try back later.', $query);
$this->pageSize = $pageSize;
if ((int)$resultpage <= 0) $resultpage = 1;
if ($resultpage > $this->getNumPages())
$resultpage = $this->getNumPages();
$this->setPageNum($resultpage);
}
}
I would like to be able to pass the results from the MySQL class to the PageResultSet class without have to do the query over and such. How would I go about coding that? I am not clear on that.
Also can I extend a function in PageResultSet that is started in MySQL??
In MySQL I have
function fetchAssoc() {
if (!$this->results) return FALSE;
$this->row++;
return mysql_fetch_assoc($this->results);
}
In PageResultSet I have function fetchAssoc() { if (!$this->results) return FALSE; if ($this->row >= $this->pageSize) return FALSE; $this->row++; return mysql_fetch_assoc($this->results); }
Can I just write something like within PageResultSet function fetchAssocPRS extends fetchAssoc () { if ($this->row >= $this->pageSize) return FALSE; }
Thanks for the help.
-- Blessed Be
Phillip
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php