db->where('t1.*, t2.*, t3.*, t4.*, t6.*, COUNT(t5.-6ren">
gpt4 book ai didi

php - 我是 PHP CodeIgniter 的新手,MySql 出现一些错误的语法错误 "Delete Join"

转载 作者:行者123 更新时间:2023-11-29 11:56:30 27 4
gpt4 key购买 nike

 public function delete($group_id)
{
$this->db->where('t1.*, t2.*, t3.*, t4.*, t6.*, COUNT(t5.id) AS total_students')
->join('groups_days AS t6', 't1.group_id = t6.group_id')
->join('groups_members AS t5', 't1.group_id = t5.group_id')
->group_by('t1.group_id')
->delete("groups AS t1")
->result();
}

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS `t1` WHERE t1., t2., t3., t4., t6.*, COUNT(t5.id) AS total_students' at line 1

DELETE FROM `groups` AS `t1` WHERE t1., t2., t3., t4., t6.*, COUNT(t5.id) AS total_students

Filename: D:/www/domains/uzdev/taraqqiyot/application/models/Group_model.php

我的删除不起作用并显示上述错误。这里出了什么问题

最佳答案

根据此链接,您无法通过加入 CodeIgniter 事件记录进行删除: link

另一个选项是使用与表数量一样多的多个查询:

$this->db->delete('groups', array('group_id'=>$group_id));
$this->db->delete('groups_days', array('group_id'=>$group_id));
$this->db->delete('groups_members', array('group_id'=>$group_id));

关于php - 我是 PHP CodeIgniter 的新手,MySql 出现一些错误的语法错误 "Delete Join",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33119765/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com