提问人:Sharkys 提问时间:7/21/2022 最后编辑:Sharkys 更新时间:7/21/2022 访问量:974
PHP 致命错误:未捕获错误:调用未定义的方法 Delete::d elete()
PHP Fatal error: Uncaught Error: Call to undefined method Delete::delete()
问:
请有人建议使此代码兼容,可能在PHP 7.4升级期间它被破坏了...这是 5 年前开发的解决方案,现在它被打破了。
我不是开发人员...因此,对于这个可能微不足道的要求,我们深表歉意。
PHP 致命错误:未捕获错误:调用未定义的方法 Delete::d elete()
$userRightModel = new UserRightDb();
$userRightSelectModel = $userRightModel->getSelectModel();
$userRightSelectModel->setWhereEqual(UserRightDb::COLUMN_USER_ID, $id);
$userRightList = $userRightSelectModel->get();
foreach($userRightList as $userRightObject) {
$userRightModel = new UserRightDb();
$userRightDeleteModel = $userRightModel->getDeleteModel();
$userRightDeleteModel->setValue($userRightObject);
$userRightDeleteModel->delete(); <--- here it's broken
}
可能 delete() 是从 Delete 调用的.php它包含在 DB.php 库中......
<?php
include_once 'MySql.php';
class Delete extends MySql {
protected $_table = null;
protected $_columns = array();
protected $_values = array();
protected $_object_name = null;
public function __construct() {
foreach($this->_values as $object) {
$queryString = $this->toString($object);
$mysql_data = $this->execute($queryString);
}
}
public function setObjectName($objectName) {
$this->_object_name = $objectName;
}
public function setTable($tableName) {
$this->_table = $tableName;
}
public function setColumns($columns) {
$this->_columns = $columns;
}
public function setValue($value) {
$this->_values = array();
$this->_values[] = $value;
}
protected function toString($object) {
$result = 'DELETE FROM {table} WHERE {where}';
$result = str_replace('{table}', '`' . $this->_table . '`', $result);
$where = Db::COLUMN_ID . MySQL::EQUAL . "'" . $object->getId() ."'";
$result = str_replace('{where}', $where, $result);
return $result;
}
}
?>
谢谢。
答: 暂无答案
评论