我的结果似乎回来了,但是为什么我的数组空白?

时间:2018-11-25 13:42:30

标签: cakephp

我有一个表,该表应按字段吸引匹配的用户。

募捐人有一个名为“ phone_referral”的字段...结果似乎回来了,但数组为空

    $fundraisersIds = $this->Fundraisers->find('list', ['conditions' => ['Fundraisers.user_id' => $this->Auth->user('id')], 'fields' => ['phone_referral', 'phone_referral']])->toArray();

数组([0] => [1] =>)

如果该数组返回正确,我正在尝试将其传递给该数组以获取用户:

$referredUsers = $this->Users->find('all')->where(['Users.referredBy IN '=>$fundraisersIds])->group('Users.referredBy')->count();

这是我的设置:

public function initialize(array $config)
{
    parent::initialize($config);

    $this->setTable('fundraisers');
    $this->setDisplayField('id');
    $this->setPrimaryKey('id');

    $this->addBehavior('Timestamp');

    $this->belongsTo('Users', [
        'foreignKey' => 'user_id',
        'joinType' => 'LEFT'
    ]);

    $this->hasMany('Users', [
        'foreignKey' => 'referredBy',
        'propertyName' => 'users'

    ]);

    $this->belongsTo('Counties', [
        'foreignKey' => 'county',
        'propertyName' => 'counties'
    ]);


}

谁能告诉我为什么会这样?

0 个答案:

没有答案