如何在codeigniter / jquery棘轮上自动检查通知?

时间:2017-04-21 01:32:49

标签: php codeigniter websocket ratchet

我想在我的应用上查看我的通知,我想从我自己的系统通知发送给没有添加它们的用户,但我该如何自动检测它们?

console.log("<?php echo $_POST["q3_fullName3[first]"]; ?>");

模型通知

public function pusher(){
         $entryData = array(
             'category' => $this->input->post('category'), 
             'title'    => $this->input->post('title'), 
             'article'  => $this->input->post('article'), 
             'when'     => time()
         );

        //$this->notification->addNotification($entryData);

        // This is our new stuff

        $context = new ZMQContext();
        $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
        $socket->connect("tcp://localhost:5555");

        $socket->send(json_encode($entryData));
        print_r($entryData);

    }

websocket jquery。

public function checkForNotifications($user_id, $lastAjaxCall){
        $sql = "SELECT COUNT(*) as notificationCount FROM storelte_user_notifications WHERE timestamp > ?  AND user_id = ?";
        $result = $this->db->query($sql, array($user_id, $lastAjaxCall))->result_array();
        print_r($result[0]['notificationCount']);
        return $result[0]['notificationCount'];
    }

    public function getNotifications($user_id, $lastAjaxCall){
        $sql =  "SELECT * FROM storelte_user_notifications LEFT JOIN storelte_notifications on storelte_user_notifications.notification_id = storelte_notifications.id WHERE timestamp > ? AND user_id = ? ORDER by timestamp";
        $result = $this->db->query($sql, array($user_id, $lastAjaxCall))->result_array();
        return $result;
    }

0 个答案:

没有答案