This should be a fairly simple question of classes and interfaces, but please bear with me as I set out my example.
In the Propel ORM library, all database tables are abstracted as classes with a name BaseTablename. Various methods of interacting with the database are defined in the base area. The library then also generates classes named after the tables, such as Tablenamethose that are super convenient for overriding basic methods and adding custom methods.
I'm just trying to override the delete()default method to be able to delete some dependent data. But when I declare an overriding method, I get the following error:
Fatal error: Tablename :: delete () declaration must be compatible with Persistent :: delete () declaration
So, given the following basic definitions, why can't I override the method delete()?
interface Persistent {
public function delete (PropelPDO $con = null);
}
class BaseTablename extends BaseObject implements Persistent {
public function delete (PropelPDO $con = null) {
doesImportantStuff();
}
}
class Tablename extends BaseTablename {
public function delete (PropelPDO $con = null) {
doMyOwnStuff();
parent::delete();
}
}
Update: I added my call to parent :: delete (), which I could not include in my source code sample. That would really make a big difference. Sorry guys and many thanks to those who confirmed the working code.
The answer was that I needed to save the parameter in all announcements and calls. My overloaded function should be read:
public function delete (PropelPDO $con = null) {
doMyOwnStuff();
parent::delete($con);
}
source
share