第三周心得体会

阅读数:651 发布时间:2016-07-31 19:19:44

作者:w3ljc 标签: w3ljc 心得体会

第三周的学习生活结束了,学习的东西也由基础转向了应用,参与了实际项目的开发,首先熟悉了整个系统的操作流程,然后开始进行数据库的设计,同时根据数据库进行API的编写,在编写API的过程中不断对任务的流程进行推敲分析从而对一个产品的理解上升了一个档次,也熟练了phalcon的配置和编写。完成了API之后就是如何调用,所以又学习了AJAX,通过异步来调用API读取数据库数据,为了能让页面渲染变得快,将AJAX获取的数据直接打到DoT模板中,在页面相应的位置进行显示。 随着周兵兵的离开,心理压力大了很多,但也是好事,有压力才有动力,在这一周高强度的编码之下觉得自己提升很快,仿佛写了大学四年都没写过那么多的代码,也对实际工作有了信心,没有原来那么胆怯流,希望自己再接再厉。

public function msg_read($app, $mt, $responseObj){
        $i = 0;
        $sender_id   = $app->request->getPost("sender_id");
        $receiver_id = $app->request->getPost("receiver_id");
        $phql = "select * from Msg where
        ( sender_id = '".$sender_id."' and receiver_id = '".$receiver_id."' and
        (delmsg = 0 or delmsg = 2)) or ( sender_id = '".$receiver_id."'
        and receiver_id = '".$sender_id."' and (delmsg = 0 or delmsg = 1))
        order by sendtime desc";
        $rows = $app->modelsManager->executeQuery($phql);
        if($rows){
            $responseObj['status'] = 1;
            $responseObj['msg']    = 'ok';
            foreach ($rows as $row) {
                $responseObj['data'][$i]['msg_id']            = $row->msg_id;
                $responseObj['data'][$i]['sender_id']         = $row->sender_id;
                $responseObj['data'][$i]['receiver_id']       = $row->receiver_id;
                $responseObj['data'][$i]['sendtime']          = $row->sendtime;
                $responseObj['data'][$i]['delmsg']            = $row->delmsg;
                $responseObj['data'][$i]['missmsg']           = 1;
                $responseObj['data'][$i]['text']              = $row->text;
                $phql1                                        = "select user_portrait as sender_portrait from User where user_uid = '".$row->sender_id."'";
                $sender_portrait                              = $app->modelsManager->executeQuery($phql1)->getFirst();
                $phql2                                        = "select user_portrait as receiver_portrait from User where user_uid = '".$row->receiver_id."'";
                $receiver_portrait                            = $app->modelsManager->executeQuery($phql2)->getFirst();
                $responseObj['data'][$i]['sender_portrait']   = $sender_portrait->sender_portrait;
                $responseObj['data'][$i]['receiver_portrait'] = $receiver_portrait->receiver_portrait;
                $i++;
                ;
            }
            $responseObj['timeSpend'] = microtime() - $mt.'ms';
        }
        return $responseObj;
    }
    public function msg_list($app, $mt, $responseObj)
    {
        $i     = 0;
        $uid   = $app->request->getPost("uid");
        $token = $app->request->getPost("token");
        $phql  = "select (select User.user_name from User where
        User.user_uid = Msg.sender_id ) as sender_name, Msg.sender_id
        from Msg where Msg.receiver_id='".$uid."'
        or Msg.sender_id ='".$uid."' group by Msg.sender_id ";
        $rows  = $app->modelsManager->executeQuery($phql);
        if($rows){
            $responseObj['status'] = 1;
            $responseObj['msg'] = 'ok';
            foreach ($rows as $row) {
                $a = (int)($row->sender_id);
                // var_dump($a);
                // die();
                $responseObj['data'][$i]['receivername'] = $row->sender_name;
                $phql2 = "select user_portrait as sender_portrait from User where user_uid = '".$a."'";
                $sender_portrait_rs = $app->modelsManager->executeQuery($phql2)->getFirst();
                if ($sender_portrait_rs) {
                    $responseObj['data'][$i]['reciver_icon'] = $sender_portrait_rs['sender_portrait'];
                    $phql1 = "select text, sendtime from Msg where
                    (sender_id = '".$a."' and receiver_id = '".$uid."')
                    or (sender_id = '".$uid."' and receiver_id = '".$a."')
                    order by sendtime desc" ;
                    $msg = $app->modelsManager->executeQuery($phql1)->getFirst();
                    $responseObj['data'][$i]['msg']  = $msg->text;
                    $responseObj['data'][$i]['time'] = $msg->sendtime;
                    $i++;
                }
            }
            $responseObj['timeSpend'] = microtime() - $mt.'ms';
        }
        else{
            $responseObj['status'] = 0;
            $responseObj['msg']    = 'error';
        }
        return $responseObj;
    }

相关文章推荐: