В моем приложении, у меня есть две модели в ассоциацииCakePHP найти ('все') возвращает только одну строку
УведомлениеbelongsTo
Профиль
Это мой Notificaiton модальный
class Notification extends AppModel {
public $name = 'Notification';
public $belongsTo = array('Profile');
public function getnotification($id = NULL){
$result = $this->find('all',array(
'conditions' => array(
'Notification.receiver_id' => $id
)
));
return $result;
}
}
Array
(
[0] => Array
(
[Notification] => Array
(
[id] => 1
[profile_id] => 8
[receiver_id] => 1
[notification_text] => tester Sent you message on project Test
[notification_descriptions] => {"projectid":"2"}
[is_active] => 1
[created_on] => 2014-08-29 18:50:38
[modified_on] => 2014-08-29 18:50:38
)
[Profile] => Array
(
[id] => 8
[user_id] => 8
[u_id] => 63c0cd43
[profile_firstname] => tester
[profile_lastname] => seller
[profile_gender] => 1
[profile_dob] => 1999-08-13
[profile_paypalid] => [email protected]
[profile_company] =>
[profile_occupation] => Web Developer
[profile_address] =>
[profile_city] =>
[profile_state] =>
[country_id] => 106
[profile_postalcode] =>
[currency_id] => 150
[timezone_id] => 93
[profile_avatar] =>
[profile_role] => 2
[profile_status] => 1
[about_me] => "But I must explain to you how all this mistaken idea"
[profile_title] =>
[rate_per_hour] =>
[language_id] => 38
[visibility] =>
[profile_rating] => 100
[is_active] => 1
[last_modified] => 2014-08-27 11:34:56
[rating] => 100
)
)
)
Но всегда возвращают первую строку из таблицы, даже если есть два или более ряда
Ожидаемый выходной
Array
(
[0] => Array
(
[Notification] => Array
(
[id] => 1
[profile_id] => 8
[receiver_id] => 1
[notification_text] => tester Sent you message on project Test
[notification_descriptions] => {"projectid":"2"}
[is_active] => 1
[created_on] => 2014-08-29 18:50:38
[modified_on] => 2014-08-29 18:50:38
)
[Profile] => Array
(
[id] => 8
[user_id] => 8
[u_id] => 63c0cd43
[profile_firstname] => tester
[profile_lastname] => seller
[profile_gender] => 1
[profile_dob] => 1999-08-13
[profile_paypalid] => [email protected]
[profile_company] =>
[profile_occupation] => Web Developer
[profile_address] =>
[profile_city] =>
[profile_state] =>
[country_id] => 106
[profile_postalcode] =>
[currency_id] => 150
[timezone_id] => 93
[profile_avatar] =>
[profile_role] => 2
[profile_status] => 1
[about_me] => "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was"
[profile_title] =>
[rate_per_hour] =>
[language_id] => 38
[visibility] =>
[profile_rating] => 100
[is_active] => 1
[last_modified] => 2014-08-27 11:34:56
[rating] => 100
)
)
[1] => Array
(
[Notification] => Array
(
[id] => 2
[profile_id] => 7
[receiver_id] => 1
[notification_text] => tester Sent you message on project Test
[notification_descriptions] => {"projectid":"2"}
[is_active] => 1
[created_on] => 2014-08-29 18:50:38
[modified_on] => 2014-08-29 18:50:38
)
[Profile] => Array
(
[id] => 7
[user_id] => 7
[u_id] => 63c0cd458
[profile_firstname] => teste
[profile_lastname] => person
[profile_gender] => 1
[profile_dob] => 1999-08-13
[profile_paypalid] => [email protected]
[profile_company] =>
[profile_occupation] => Web Developer
[profile_address] =>
[profile_city] =>
[profile_state] =>
[country_id] => 106
[profile_postalcode] =>
[currency_id] => 150
[timezone_id] => 93
[profile_avatar] =>
[profile_role] => 2
[profile_status] => 1
[about_me] => "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a c
[profile_title] =>
[rate_per_hour] =>
[language_id] => 38
[visibility] =>
[profile_rating] => 100
[is_active] => 1
[last_modified] => 2014-08-27 11:34:56
[rating] => 100
)
)
)
В то время как $this->element('sql_dump');
показывает 3 строки были затронуты в связи с запросом, но когда я печать результат, он показывает только один результат, даже count
& sizeof
показать 1
.
Рассмотрим profile_id
как sender_id
Может ли один скажите мне, где и что я делаю неправильно?
может быть проще понять вашу проблему, если вы разместите пример записей в таблице, массив, вы получаете и то, что ожидаемый выход – Nunser
ожидается выход независимо находка («все») метод возвращает, все строки, которые удовлетворяют пройденным условиям – user3873381