[英]Phalcon PHP extend and override “update” and “insert” functions
I would like to implement my own database dialect in Phalcon PHP. 我想在Phalcon PHP中实现自己的数据库方言。 I would like to extend and override few functions that are already reserved for PDO.
我想扩展和覆盖一些已经为PDO保留的功能。 This is what I'm trying to do:
这就是我想要做的:
class DB extends \Phalcon\Db\Adapter\Pdo\Mysql{
function _construct($connection_variables=array())
{
parent::_construct($connection_variables);
}
function update($table="",$variables="")
{
parent::execute($query);
}
}
So, when I try to to call in the model: 因此,当我尝试调用模型时:
$this->db->update('test',array('id'=>'1'));
It gives me an error stating that: 它给我一个错误,指出:
Fatal error: Declaration of Libraries\DB::update() must be compatible with Phalcon\Db\AdapterInterface::update($table, $fields, $values, $whereCondition = NULL, $dataTypes = NULL) in .....
How can I override update and insert functions? 如何覆盖更新和插入功能? Thanks
谢谢
Your update
method must match with the method declared in the Phalcon\\Db\\AdapterInterface
interface, it should be: 您的
update
方法必须与Phalcon\\Db\\AdapterInterface
接口中声明的方法匹配,它应该是:
function update($table, $fields, $values, $whereCondition = NULL, $dataTypes = NULL)
{
// ...
}
Instead of: 代替:
function update($table="",$variables="")
{
// ...
}
The method signature/header
must be the same as it is in the interface
. 方法
signature/header
必须与interface
的相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.