在模型

时间:2016-04-02 10:38:30

标签: activerecord codeigniter-2

我有桌子

  • table1(id,name)
  • table2(id,name,active)

table2中有效的字段包含值' 0'或者' 1'

我在模特中的关系是

static $has_many = array(
        array('table2', 'conditions' => array('active = ?' => array(0)))
    );

后来我必须找到所有的地方

table2.active =' 1'

但现在我收到的错误是:

遇到PHP错误

严重性:注意

消息:未定义的偏移量:0

文件名:lib / Relationship.php

1 个答案:

答案 0 :(得分:1)

条件值的

应该是标量(字符串,数字,布尔值)

$has_many = array(
            array('table2', 'conditions' => array('active' => 0))
        );

仅在查询中使用 IN 条件时才必须使用数组。