【问题标题】:Delete with join in codeigniter在codeigniter中加入删除
【发布时间】:2015-04-27 14:15:33
【问题描述】:
function delete_ScormByIdPlataforma($id_platform)
    {
        $query = $this->db->query("delete from scormvars where scoinstanceid in
                (select scoinstanceid from dispatch where id_licencia in 
                (select id_licencia from licencias where id_plataforma = $id_platform))");
        // return true;
    }

这是我模型中的函数,查询没问题,但是不知道怎么执行查询。

【问题讨论】:

  • 如果您的数据库在 application/config/database 中配置良好,这就是您在 codeigniter 中执行查询的方式。如果查询成功或失败,这里 $query 是 true 或 false。你可以写:function delete_ScormByIdPlataforma($id_platform) { return $this->db->query("delete from scormvars where scoinstanceid in (select scoinstanceid from dispatch where id_licencia in (select id_licencia from licencias where id_plataforma = $id_platform))"); }
  • 好的,现在我收到一个错误:不允许删除,除非它们包含“where”或“like”子句。文件名:C:\wamp\www\WiccoCloud\system\database\DB_active_rec.php 行号:1567
  • 我想你应该在这里找到你需要的东西:stackoverflow.com/questions/26589378/…

标签: php codeigniter


【解决方案1】:

你加载模型类,然后调用函数:

$this->load->model('my_class');
$this->my_class->delete_ScormByIdPlataforma($id_platform);

my_class 替换为类的名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-24
    • 1970-01-01
    • 2013-07-15
    • 2013-04-19
    • 2012-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多