I want to check if notificatins are > 0 then there are notification else then there are no notifications available, but however if I change status to 1 my rows goes to my second if - else seen, but I want to check how many notifications are seen or unread , but if I change status count like all
public function websocket(){
$data = $this->session->userdata('log');
$user_id = $data['id'];
$timestamp = 1493618633;
// $entryData = array(
// 'category' => $_POST['category'],
// 'title' => $_POST['title'],
// 'article' => $_POST['article'],
// 'when' => time()
// );
$array = $this->notification->getNotifications($timestamp, $user_id);
if ($array > 0) {
if (empty(array_filter(array_column($array, 'status')))) {
echo 'unread';
}else{
echo 'seen';
}
}else{
$this->json(array('msg' => 'there are no notifications available'));
}
$context = new ZMQContext();
$socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
$socket->connect("tcp://localhost:5555");
$socket->send(json_encode('hola'));
}
Based on your code, you're only checking if $array
exists (which it does because it's initialized in the line directly above). If using count($array) > 0
or $array.size() > 0
is still returning the undesired result, try throwing a quick and dirty print_r($array)
right after the initialization of the variable to check and make sure that your notification system isn't returning an empty or malformed array.