在模型中应用条件时遇到 PHP 错误

A PHP error was encountered when conditions are applied in model

我有桌子

table2 中的活动字段包含值“0”或“1”

我模型中的关系是

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

稍后我必须找到所有地方

table2.active = '1'

但现在我收到错误:

遇到了一个PHP错误

严重性:通知

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

文件名:lib/Relationship.php

条件值应该是标量(字符串、数字、布尔值)

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

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