【问题标题】:CodeIgniter: active record SET taking second field name as string value instead of field nameCodeIgniter:活动记录 SET 将第二个字段名称作为字符串值而不是字段名称
【发布时间】:2020-12-21 03:56:36
【问题描述】:

请看下面的简单代码。在 SET 命令中,它应该将两个参数都作为字段名称,而不是将第二个参数作为字符串值

$var = '2020-11-01 01:33:51';
        $var1 = id;
    $this->db->set('location', call_type);
    $this->db->where('call_date', $var);
    if($this->db->update('phone_acc')) {

            return true;
    } else {
            return false;
    }

创建此查询的这些语句:

     UPDATE `phone_acc` SET `location` = 'call_type' WHERE `call_date` = '2020-11-01 01:33:51'

call_type 是字段名而不是字符串值。它应该将“call_type”读取为字段名称。请问我该怎么做。

【问题讨论】:

    标签: codeigniter activerecord set updates


    【解决方案1】:

    要使另一个变量作为字段名,我们需要在语句中添加一个标志'false',就像这样;

     $this->db->set('location', 'call_type', false);
    

    【讨论】:

      猜你喜欢
      • 2022-11-11
      • 2012-01-29
      • 2012-01-17
      • 2011-12-17
      • 2016-02-06
      • 2020-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多