我可以添加数组到where子句在codeigniter update_batch [英] can I add array to where clause to update_batch in codeigniter

查看:332
本文介绍了我可以添加数组到where子句在codeigniter update_batch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用codeigniter update_batch 函数。

I am using codeigniter update_batch function.

我想传递一个数组作为第三个参数子句)到 update_batch

I want to pass an array as the third parameter (where clause) to update_batch.

$data = array(
   array(
      'title' => 'My title' ,
      'name' => 'My Name 2' ,
      'date' => 'My date 2'
   ),
   array(
      'title' => 'Another title' ,
      'name' => 'Another Name 2' ,
      'date' => 'Another date 2'
   )
);

而不是这样:

$this->db->update_batch('mytable', $data, 'title'); 

我想这样做:

 $this->db->update_batch('mytable', $data, array('title','name')); 

因此添加条件的倍数。

推荐答案

您可以随时这样做:

$data = array(
   array(
      'title' => 'My title' ,
      'name' => 'My Name 2' ,
      'date' => 'My date 2'
   ),
   array(
      'title' => 'Another title' ,
      'name' => 'Another Name 2' ,
      'date' => 'Another date 2'
   )
);
$this->db->where(array('title' => 'title', 'name' => 'name'));
$this->db->update_batch('mytable', $data);

未测试。

UPDATE 缺少 update_batch()中所需的其中参数。

这篇关于我可以添加数组到where子句在codeigniter update_batch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆