snllll 发表于 2010-9-3 00:01:52

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

print_r($pid)的结果:
----------------------------------------
Array
(
    => 212
    => 210
    => 53
    => 211
)
-----------------------------------------
这个是送进去查询用到的ID;
$this->db->where_in('pid',$pid);
返回的结果打印出来是这样的:
---------------------------------------------
Array
(
    => Array
      (
             => 53
      )
    => Array
      (
             => 210
      )
    => Array
      (
             => 212
      )
)
----------------------------------------------

有一行被CI给吃掉了,如何解决?

snllll 发表于 2010-9-3 00:04:47


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;
}

snllll 发表于 2010-9-3 00:09:39

SQL正常呢:
SELECT *
FROM (`table`)
WHERE `pid` IN ('212', '210', '53', '211')

snllll 发表于 2010-9-3 00:12:43

哦~事实证明,我在navcat中运行该SQL,返回的结果的确只有三行。

Hex 发表于 2010-9-3 01:40:42

。。。。。
CI 不可能会吃你的内容。。
你的思考方向就不对,呵呵

snllll 发表于 2010-9-5 06:50:26

回复 5# Hex


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

    在命令行下也只有返回三行,我不知何故。

sonic 发表于 2010-9-8 16:35:09

三行什么?
页: [1]
查看完整版本: $this->db->where_in(); 的返回结果只有三列数据!