用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4669|回复: 6
收起左侧

[已过期] $this->db->where_in(); 的返回结果只有三列数据!

[复制链接]
发表于 2010-9-3 00:01:52 | 显示全部楼层 |阅读模式
print_r($pid)的结果:
----------------------------------------
Array
(
    [0] => 212
    [1] => 210
    [2] => 53
    [3] => 211
)
-----------------------------------------
这个是送进去查询用到的ID;
$this->db->where_in('pid',$pid);
返回的结果打印出来是这样的:
---------------------------------------------
Array
(
    [0] => Array
        (
            [pid] => 53
        )
    [1] => Array
        (
            [pid] => 210
        )
    [2] => Array
        (
            [pid] => 212
        )
)
----------------------------------------------

有一行被CI给吃掉了,如何解决?
 楼主| 发表于 2010-9-3 00:04:47 | 显示全部楼层
PHP复制代码
 
 function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ')
 {
  if ($key === NULL OR ! is_array($values))
  {
   return;
  }
  $not = ($not) ? ' NOT ' : '';
  foreach ($values as $value)
  {
   $this->ar_wherein[] = $this->escape($value);
  }
  $prefix = (count($this->ar_where) == 0) ? '' : $type;
 
  $where_in = $prefix . $this->_protect_identifiers($key) . $not . " IN (" . implode(", ", $this->ar_wherein) . ") ";
  $this->ar_where[] = $where_in;
  if ($this->ar_caching === TRUE)
  {
   $this->ar_cache_where[] = $where_in;
  }
  // reset the array for multiple calls
  $this->ar_wherein = array();
  return $this;
 }
 
复制代码
 楼主| 发表于 2010-9-3 00:09:39 | 显示全部楼层
SQL正常呢:
SELECT *
FROM (`table`)
WHERE `pid` IN ('212', '210', '53', '211')
 楼主| 发表于 2010-9-3 00:12:43 | 显示全部楼层
哦~事实证明,我在navcat中运行该SQL,返回的结果的确只有三行。
发表于 2010-9-3 01:40:42 | 显示全部楼层
。。。。。
CI 不可能会吃你的内容。。
你的思考方向就不对,呵呵
 楼主| 发表于 2010-9-5 06:50:26 | 显示全部楼层
回复 5# Hex


    SELECT * FROM (`table`) WHERE `pid` IN ('212', '210', '53', '211')

    在命令行下也只有返回三行,我不知何故。
发表于 2010-9-8 16:35:09 | 显示全部楼层
三行什么?

本版积分规则