CakePHP - HasOne关系检索空数据

时间:2013-06-15 20:19:43

标签: cakephp belongs-to has-one

我有这两个类:

class Client extends AppModel{
    public $belongsTo = array(
        'User',
        'plans' => array(
            'className'    => 'Plan',
            'foreignKey'   => 'plans_id'
        )
    );

    public $hasMany = array(
        'Order'
    );
}

}

class User extends AppModel{

public $belongsTo = array(
    'Rol' => array(
        'fields' => array('id', 'nombre')
    )
);

public $hasOne = array(
    'Client'
);

}

然而,蛋糕检索了这个:

'User' => array(
        'password' => '*****',
        'id' => '32',
        'username' => 'test_admin',
        'correo_electronico' => 'a@d.com',
        'created' => '2013-06-09 19:58:18',
        'modified' => '2013-06-09 19:58:18',
        'esta_habilitado' => '1',
        'rol_id' => '1'
    ),
    'Rol' => array(
        'id' => '1',
        'nombre' => 'Administrador'
    ),
    'Client' => array(
        'id' => null,
        'primer_nombre' => null,
        'segundo_nombre' => null,
        'primer_apellido' => null,
        'segundo_apellido' => null,
        'direccion' => null,
        'diudad' => null,
        'telefono' => null,
        'rating' => null,
        'created' => null,
        'modified' => null,
        'esta_habilitado' => null,
        'plans_id' => null,
        'user_id' => null
    )

任何想法发生了什么,我检查了数据库中的外键,用户的id对应于客户端记录中的user_id

0 个答案:

没有答案
相关问题