1

I am working on a new widget for Tomato CMS and they use an interface:

interface Ad_Models_Interface_BannerPageAssoc
{
    ...

    /**
     * Get banner-page by Zone Id
     * 
     * @param int $zoneId Id of zone
     */
    public function getByZoneId($zoneId);
}

and another class that implements this interface:

class Ad_Models_Dao_Mysql_BannerPageAssoc extends Tomato_Model_Dao
implements Ad_Models_Interface_BannerPageAssoc
{

    public function getByZoneId($zoneId)
    {
      $sql  = sprintf("SELECT * FROM " . $this->_prefix . "ad_page_assoc");
      $rs   = mysql_query($sql);
      $rows = array();
      while ($row = mysql_fetch_object($rs)) {
        $rows[] = $row;
      }
      mysql_free_result($rs);
      return new Tomato_Model_RecordSet($rows, $this);
    }
}

When I make an object of this class and call the function, I get this error:

Fatal error: Class Ad_Models_Dao_Pdo_Mysql_BannerPageAssoc contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Ad_Models_Interface_BannerPageAssoc::getByZoneId) in C:\xampp\htdocs\roepingen\application\modules\ad\models\dao\pdo\mysql\BannerPageAssoc.php on line 59

Does anyone have an idea how I can solve this problem?

2 Answers 2

1

Ad_Models_Dao_Mysql_BannerPageAssoc is not the same class as in the error: Ad_Models_Dao_Pdo_Mysql_BannerPageAssoc.

Sign up to request clarification or add additional context in comments.

1 Comment

This is indeed my fault ... Thanks for noticing :-)
0

There may be a problem between your use of the keywords interface/abstract and extends/implements. You don't mention the class you actually get the error on, which is Ad_Models_Dao_Pdo_Mysql_BannerPageAssoc. That class must also implement the required methods if it implements Ad_Models_Interface_BannerPageAssoc. Interfaces are treated differently than abtract classes in PHP.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.