note 83153 added to language.oop5.abstract
| From: | keithjfrank at gmail dot com | Date: | Tue, 13 May 2008 08:19:02 +0000 |
| Subject: | note 83153 added to language.oop5.abstract | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139326@lists.php.net to get a copy of this message | ||
While building my database class, I came across something I didn't see any documentation on...
abstract class db
{
abstract protected function prepareSelect();
}
class dbPlugin extends db
{
/**
* Prepare Select
* Populates $this->currentQuery with MySQL formatted SELECT query.
*
* @param string Fields to retrieve
* @param string Table from which fields will be selected
* @param string Optional WHERE restriction
**/
protected function prepareSelect( $fields, $table, $where = NULL )
{
$this->currentQuery .= "SELECT {$fields} FROM
{$this->dbSettings['sqlPrefix']}{$table}";
if ( $where !== NULL )
{
$this->currentQuery .= " WHERE {$where}";
}
}
}
While executing the script I was greeted with: Fatal error: Declaration of
dbPlugin::prepareSelect() must be compatible with that of db::prepareSelect() in
[...]\includes\plugins\dbMySQL.php on line 209
The fix? Adding the same expected variables to the parent abstract method.
abstract class db
{
abstract protected function prepareSelect( $fields, $table, $where );
}
I am unsure as to whether this is common knowledge or not, but I figured I would share to ease
someone else's frustration while figuring out what was going awry. :)
----
Server IP: 208.69.120.35
Probable Submitter: 74.70.179.203
----
Manual Page -- http://www.php.net/manual/en/language.oop5.abstract.php
Edit -- https://master.php.net/note/edit/83153
Del: integrated -- https://master.php.net/note/delete/83153/integrated
Del: useless -- https://master.php.net/note/delete/83153/useless
Del: bad code -- https://master.php.net/note/delete/83153/bad+code
Del: spam -- https://master.php.net/note/delete/83153/spam
Del: non-english -- https://master.php.net/note/delete/83153/non-english
Del: in docs -- https://master.php.net/note/delete/83153/in+docs
Del: other reasons-- https://master.php.net/note/delete/83153
Reject -- https://master.php.net/note/reject/83153
Search -- https://master.php.net/manage/user-notes.php