当前位置: 首页>>代码示例>>PHP>>正文


PHP Chat::model方法代码示例

本文整理汇总了PHP中Chat::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::model方法的具体用法?PHP Chat::model怎么用?PHP Chat::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chat的用法示例。


在下文中一共展示了Chat::model方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadModelById

 public function loadModelById($id)
 {
     $model = Chat::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     } else {
         return $model;
     }
 }
开发者ID:GsHatRed,项目名称:Yiitest,代码行数:9,代码来源:ChatController.php

示例2: yiichat_list_posts

 /**
  * 
  * @param integer $relatedID
  * @param integer $userID
  * @param integer $lastID
  * @param mixed $data
  * @return Chat[]
  */
 public function yiichat_list_posts($relatedID, $userID, $lastID, $data)
 {
     $limit = 3;
     $rows = array();
     if ($lastID == -1) {
         $chats = Chat::model()->findAll(array('order' => 'datetime ASC', 'condition' => 'relatedID = :relatedID', 'params' => array(':relatedID' => $relatedID)));
         foreach ($chats as $key => $chat) {
             $rows[$key] = $this->restructureChat($chat);
         }
     } else {
         $chats = Chat::model()->findAll(array('condition' => 'userID != :userID AND relatedID = :relatedID', 'order' => 'datetime DESC', 'params' => array(':userID' => $userID, ':relatedID' => $relatedID)));
         $lastChats = $this->getLastPosts($chats, $limit, $lastID);
         foreach ($lastChats as $key => $lastChat) {
             $rows[$key] = $this->restructureChat($lastChat);
         }
     }
     return $rows;
 }
开发者ID:andryluthfi,项目名称:annotation-tools,代码行数:26,代码来源:ChatHandler.php

示例3: actionSave_chat

 /**
  * Добавление, редактирование, удаление сообщений в чате
  */
 public function actionSave_chat()
 {
     if (!Yii::app()->user->isGuest) {
         if (Yii::app()->request->isAjaxRequest) {
             $result = false;
             if (isset($_POST['idChat'])) {
                 $model = Chat::model()->findAllByPk((int) $_POST['idChat']);
             } else {
                 $model = new Chat();
             }
             switch ($_POST['action']) {
                 case 'add':
                     $model->text = trim(htmlspecialchars($_POST['text']));
                     $model->idUser = empty($this->_user) ? Users::getIdUserForAdmin() : $this->_user['idUser'];
                     if ($model->save()) {
                         $model->date = date('d.m.Y H:i', $model->date);
                         $model->nameUser = empty($this->_user) ? 'Админ' : (!empty($this->_user['lastFirstName']) ? $this->_user['lastFirstName'] : $this->_user['login']);
                         $result = $model;
                     }
                     break;
                 case 'edit':
                     if ($model->update(array('active' => (int) $_POST['active']))) {
                         $result = $model;
                     }
                     break;
                 case 'delete':
                     if ($model->delete()) {
                         $result = true;
                     }
                     break;
             }
             echo CJSON::encode(array('result' => $result));
             exit;
         }
     }
 }
开发者ID:vitalya-xxx,项目名称:vitacod.ru,代码行数:39,代码来源:ChatController.php

示例4: date

<?php

$date = date('Y-m-d H:i:s', strtotime("-30  minutes"));
$all = Chat::model()->findAll("id > :last and time > :lt", array('last' => $last, 'lt' => $date));
$cont = "";
$id = 0;
foreach ($all as $msg) {
    $cont .= "<div class='chat-msg' id='{$msg->id}' >\n";
    $cont .= "<div class='chat-user'>{$msg->user}</div>\n";
    $cont .= "<div class='chat-time'>{$msg->time}</div>\n";
    $cont .= "<div class='chat-content'>{$msg->content}</div>\n";
    $cont .= "</div>\n";
    $id = $msg->id;
}
if ($id == 0) {
    $id = Yii::app()->db->createCommand()->select('max(id)')->from('chat')->queryScalar();
}
echo json_encode(array('content' => $cont, 'last_id' => $id));
开发者ID:black2279,项目名称:Tracy-openshift,代码行数:18,代码来源:chat-raw.php

示例5: model

 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return Chat the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
开发者ID:nguyendvphp,项目名称:onlinetraining,代码行数:10,代码来源:WChat.php

示例6: deleteChatMsg

 public function deleteChatMsg($idChat)
 {
     Chat::model()->deleteByPk($idChat);
 }
开发者ID:vitalya-xxx,项目名称:vitacod.ru,代码行数:4,代码来源:DefaultController.php


注:本文中的Chat::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。