* Fixed an issue where the objectType was incorrect when deleting.

This commit is contained in:
tianshujie
2023-09-07 11:03:57 +08:00
parent 11beb0f7ab
commit 0b44f74b68
2 changed files with 7 additions and 6 deletions
+6 -5
View File
@@ -56,16 +56,17 @@ class model extends baseModel
* 删除记录
* Delete one record.
*
* @param string $table the table name
* @param string $id the id value of the record to be deleted
* @param string $table the table name
* @param string $id the id value of the record to be deleted
* @param string $objectType the object type of the record to be deleted
* @access public
* @return bool
*/
public function delete($table, $id)
public function delete($table, $id, $objectType = '')
{
$this->dao->update($table)->set('deleted')->eq(1)->where('id')->eq($id)->exec();
$object = preg_replace('/^' . preg_quote((string) $this->config->db->prefix) . '/', '', trim($table, '`'));
$this->loadModel('action')->create($object, $id, 'deleted', '', actionModel::CAN_UNDELETED);
if(!$objectType) $objectType = preg_replace('/^' . preg_quote((string) $this->config->db->prefix) . '/', '', trim($table, '`'));
$this->loadModel('action')->create($objectType, $id, 'deleted', '', ACTIONMODEL::CAN_UNDELETED);
return true;
}