CakePHP和Mongodb

时间:2012-12-16 04:04:59

标签: php cakephp

我正在使用CakePHP 2.2.4和Mongodb 2.2.2

我已经解决了几个问题,但在我的cakephp主页上遇到以下错误

Strict (2048): Declaration of MongodbSource::execute() should be compatible with DboSource::execute($sql, $options = Array, $params = Array) [APP/Plugin/Mongodb/Model/Datasource/MongodbSource.php, line 36]

我为这些函数声明得到了类似的错误

  • MongodbSource :: query()
  • MongodbSource ::创建()
  • MongodbSource ::读()
  • MongodbSource :: update()
  • MongodbSource ::删除()
  • MongodbSource ::计算()
  • MongodbSource ::组()
  • MongodbSource :: DROPSCHEMA()
  • MongodbSource ::描述()

MongodbSource扩展了DbSource

在DbSource中:

public function execute($sql, $options = array(), $params = array()) { <code here> }
MongodbSource中的

public function execute($query, $params = array()) { <code here> }

我有点理解发生了什么,但我不确定如何解决它。

1 个答案:

答案 0 :(得分:1)

覆盖父方法的方法应该实现相同的参数,即execute中的MongodbSource方法签名应该是:

public function execute($sql, $options = array(), $params = array())

另见:

Declaration of Methods should be Compatible with Parent Methods in PHP

https://www.google.com/search?q=php+Declaration+of+should+be+compatible+with

http://php.net/manual/en/migration51.oop.php#migration51.oop-inheritance