【发布时间】:2011-02-27 09:38:04
【问题描述】:
大家好,我正在尝试从我的 events_controller.php 文件中的数组中获取一个值。 Event belongsTo Entity 和 Entity hasMany 事件。我需要这个值来执行其他一些逻辑,但我真的卡住了,我知道这应该是一件容易的事。
我正在尝试从这个数组中获取 Entity.user_id 的值。
Array
(
[Event] => Array
(
[id] => 19
[entity_id] => 8
[name] => new event
[time_start] => 2011-02-26 19:09:00
[time_end] => 2011-02-26 19:09:00
[dateStart] => 0000-00-00
[dateEnd] => 0000-00-00
[description] => jgiuguygo
[ageRange] => 67
)
[Entity] => Array
(
[id] => 8
[user_id] => 14
[location_id] => 15
[type] => EVENT
)
[Eventfeedback] => Array
(
)
)
我用这段代码得到的上述矩阵:
$value = $this->Event->read();
pr($value);
现在这是我能得到的最接近了......
Array
(
[Entity] => Array
(
[user_id] => 14
)
[Event] => Array
(
[id] => 19
)
[Eventfeedback] => Array
(
)
)
使用此代码
$value = $this->Event->read('Entity.user_id');
pr($value);
最后一次尝试我得到了这个数组
Array
(
[Entity] => Array
(
[id] => 1
[user_id] => 11
[location_id] => 8
[type] => sdfsdfdsf
)
[User] => Array
(
[id] => 11
[firstName] => luis
[lastName] => pooya
[username] => admin
[password] => 94c882c8506497a9f031ca5a4db6d0143c97fe45
[role] => admin
[email] => some
)
[Location] => Array
(
[id] => 8
[name] => First Nation University of Canada
[xCoordinate] => 0
[yCoordinate] => 0
)
[Establishment] => Array
(
)
[Event] => Array
(
)
[Vmachine] => Array
(
)
)
使用此代码
$value = $this->Event->Entity->find('user_id');
pr($value);
希望有人可以帮助我。提前致谢。Luis
【问题讨论】: