$notification = $notification_M->getNotificationByTitle('unregistered'); // zwraca obiekt notifikacja $users = $user_M->getUnregisteredNotified($notification); // zwraca uzytwkonikow z bd + tworzy nowy obiekt notifikacja_wyslana ktora nadpisuje wczesniejsza. class UserManager { public function getUnregisteredNotified($notification) { $sql = mysql_query("SELECT users.id, notifications_sent.id as 'notification_sent_id' FROM users, notifications_sent WHERE users.status = 2 AND users.id = notifications_sent.user_id AND notifications_sent.sent = 0 AND users.time < DATE_SUB(NOW(), INTERVAL '264' DAY) ORDER BY users.time DESC "); $this->handler($sql); return $this->userContainer; } private function handler($sql) { { $user = new User(); $user->setId($row['id']); $this->userContainer[] = $user; if($row['notification_sent_id']) { notificationManager::setSentNotification($row['notification_sent_id']); } } } }// koniec klasy userManager. class notificationManager { private $sentNotification; public function setSentNotification($param) { $this->sentNotification = new SentNotification(); $this->sentNotification->setSentId($param); } public function getSentNotification() { return $this->sentNotification; } } // koniec klasy
Generalnie chodzi o to ze przypisuje do zmiennej private sentNotificaion klasy NotifiacionManager obiekt new SentNotification. I wszystko cacy, moge kozystac z metod tego obiektu dzieki tej referencji. Lecz jak sie odwoluje do tego obiektu spoza klasy to juz wtedy mi mowi ze jest gupi i ze " Call to a member function getSentId() on a non-object in "
$dupa = $notification_M->getSentNotification()->getSentId();
Czemu tak ? Co pominalem.