CakePHP查找条件不会出现在SQL查询中

aDv*_*Dvo 1 cakephp find where conditional-statements

我的查找条件似乎没有进入基于Debugkits SQL日志的SQL.有人能向我指出我做错了什么吗?这是我第一次尝试过滤查找结果.

BillingCenters控制器

$conditions = array(
    'BillingCenter.isactive' => '1'
);
$this->set(
    'billingcenters', 
    $this->BillingCenter->find('all', array($conditions))
);
Run Code Online (Sandbox Code Playgroud)

DebugKit显示的结果SQL查询是..(缺少WHERE子句???)

SELECT 
    `BillingCenter`.`id`, 
    `BillingCenter`.`startdate`, 
    `BillingCenter`.`enddate`, 
    `BillingCenter`.`name`, 
    `BillingCenter`.`isactive`, 
    `BillingCenter`.`created`, 
    `BillingCenter`.`modified` 
FROM 
    `bm`.`billing_centers` AS `BillingCenter` 
WHERE 
    1 = 1
Run Code Online (Sandbox Code Playgroud)

如果我将控制器代码更改为

$this->set(
    'billingcenters', 
    $this->BillingCenter->find('all')
);
Run Code Online (Sandbox Code Playgroud)

生成的SQL仍然是相同的.

SELECT 
    `BillingCenter`.`id`, 
    `BillingCenter`.`startdate`, 
    `BillingCenter`.`enddate`, 
    `BillingCenter`.`name`, 
    `BillingCenter`.`isactive`, 
    `BillingCenter`.`created`, 
    `BillingCenter`.`modified` 
FROM 
    `bm`.`billing_centers` AS `BillingCenter` 
WHERE 
    1 = 1
Run Code Online (Sandbox Code Playgroud)

Ben*_*ock 5

这一直困扰着我.

将您的查找行更改为:

$this->set(
    'billingcenters', 
    $this->BillingCenter->find('all', array('conditions' => $conditions))
);
Run Code Online (Sandbox Code Playgroud)