CakePHP Hash :: diff工作不正常

时间:2015-07-24 06:23:24

标签: php arrays cakephp

我想向我的视图发送2个数组 - 第二个数组不应该包含第一个数组。我使用了Hash :: diff,但它对CakePHP数组并不起作用。

    $edited = $this->Instrument->find('all', array(
         'conditions'=>array(
            'status' => '1'),
        'fields' => array('Instrument.id',[and other fields]),
         'order'=> array('modified'=>'desc'),
         'limit'=>100
     ));


    $new = $this->Instrument->find('all', array(
         'conditions'=>array(
            'status' => '1'),
        'fields' => array('Instrument.id', [and other fields]),
         'order'=> array('added'=>'desc'),
         'limit'=>5
     ));


 $this->set(array(
     'edytowane'=>Hash::diff($edited, $new),
     'nowe'=>$new
 ));

但之后我有时在$edytowane$new变量中的记录相同。我错了什么? :)

1 个答案:

答案 0 :(得分:0)

我这样做了 - 它有点效率不高,但对我来说效果很好:

COUNT(DISTINCT Phone)              AS NumPhone,
    FROM   [BINextGen].[dbo].[tbFCCDefectReport]
    WHERE LastName IS NOT NULL
    GROUP  BY EncounterId,
              facilitycode,