当关系是belongsTo时,我如何在cakephp中从此Array编写client_id

时间:2015-02-17 11:16:54

标签: arrays cakephp

我想给出条件,其中client_id = $ this-> user ['client_id'];以便loggedIn用户可以看到他自己的客户数据。

我不明白如何从数组下面获取client_id。

[Payment] => Array
            (
                [id] => 1
                [location_id] => 138
                [cashier_id] => 313
                [client_id] => 2
                [pay_date] => 2015-02-13 10:51:54
                [amount_paid] => 28882685
                [total_paid] => 28882685
                [change_due] => 0
                [pay_method] => CA
                [bank] => 
                [ref_no] => 
                [payment_type] => Bill
                [reversal_fee] => 
                [reversal_code] => 
                [reversal] => 1
                [reversal_date] => 
                [reversed_by_id] => 
                [User] => Array
                    (
                        [id] => 313
                        [username] => tellerb
                        [client_id] => 8
                    )

                [Location] => Array
                    (
                        [id] => 138
                        [name] => Sector 64
                    )

            )

你的帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

将其用作嵌套关联数组

$YourArray['Payment']['User']['client_id'];

始终检查您是如何到达该字段的。这里的外部数组是付款,然后你转到用户然后转到client_id。