嘿傢伙我想從我的events_controller.php文件中獲取數組的值。 事件belongsTo實體和實體hasMany事件。我需要這個價值來執行一些其他的邏輯,但我真的堅持,我知道這應該是一件容易的事情。在數組中找到值cakephp
我想從這個數組中獲取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);
希望有人能幫助我。在此先感謝。路易斯
謝謝您的幫助。有效 – allegjdm93 2011-03-01 08:47:18