duandi8852752 2011-12-05 11:33
浏览 24

在codeigniter php准备好的声明

SELECT answer into @a from progress where id = 1;
SELECT answer into @b from progress where id = 2;
SELECT answer into @c from progress where id = 3;

SET @query = CONCAT('select ?, ?, ', @c);
PREPARE stmt1 from @query;
EXECUTE stmt1 using @a, @b;

I would like to write the equivalent of this using the codeigniter model but I can't work out how to do it.

My database looks like this:

table name: progress

id  label_id  answer
1      1        5
2      2        10
3      3        @a+@b

table name: master

id   label
1      a
2      b
3      c

Can anyone suggest how this would be done?

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • dqtl46964 2011-12-05 12:31
    关注

    CodeIgniter doesn't have any build in mechanic to execute a SELECT INTO statement. I've been working on a project in CodeIgniter too, I'm currently working on replacing the default database code (which they call activerecord for some reason) with PDO. The only way to do this is something along these lines

    $query = "SELECT * INTO :table FROM somethingelse";
    $query = str_replace(':table' , 'yourtablename', $query);
    $this->db->query($query);
    //.. rest of your code here
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?