當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DbHandler::getConnection方法代碼示例

本文整理匯總了PHP中DbHandler::getConnection方法的典型用法代碼示例。如果您正苦於以下問題:PHP DbHandler::getConnection方法的具體用法?PHP DbHandler::getConnection怎麽用?PHP DbHandler::getConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DbHandler的用法示例。


在下文中一共展示了DbHandler::getConnection方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getUserId

 protected static function getUserId($username)
 {
     $conn = DbHandler::getConnection();
     $query = "SELECT id FROM users WHERE username = '" . $conn->escapeString($username) . "'";
     $user_id = $conn->querySingle($query);
     return $user_id;
 }
開發者ID:krixisLv,項目名稱:SimpleChat,代碼行數:7,代碼來源:UserHandler.php

示例2: insertMessage

 public static function insertMessage($user_id, $chat_id, $message)
 {
     $conn = DbHandler::getConnection();
     $query = "INSERT INTO messages (chat_id, user_id, message, insert_time) " . "VALUES (" . $conn->escapeString($chat_id) . ", " . $conn->escapeString($user_id) . ", '" . $conn->escapeString($message) . "', " . $conn->escapeString(getMicrotime()) . ")";
     $conn->exec($query);
     UserHandler::setUserActivity();
     return true;
 }
開發者ID:krixisLv,項目名稱:SimpleChat,代碼行數:8,代碼來源:MessageHandler.php

示例3:

<?php

/**
 * Created by PhpStorm.
 * User: Kristaps
 * Date: 11/27/2015
 * Time: 1:15 AM
 */
require_once "handlers/SessionsHandler.php";
SessionsHandler::startSession();
SessionsHandler::checkAccess("chatroom.php");
require_once "handlers/DbHandler.php";
$conn = DbHandler::getConnection();
require_once "handlers/ChatHandler.php";
require_once "handlers/UserHandler.php";
$chatroom_name = UserHandler::getUsername(ChatHandler::PUBLIC_CHAT_ID);
$username = UserHandler::getCurrentUserName();
require_once "header.php";
?>
<div id="chat">
<div id="chat-content">
    <div style="header">
        <h1 id="topic">
            ChatRoom :: <span id="chat_name"><?php 
echo $chatroom_name;
?>
</span>
        </h1>
        click on user for private chat
        <div id="logout">
            <a href="operations.php?action=logout" class="button">
開發者ID:krixisLv,項目名稱:SimpleChat,代碼行數:31,代碼來源:chatroom.php

示例4: updateChatActivity

 protected static function updateChatActivity($user_id, $chat_id)
 {
     $conn = DbHandler::getConnection();
     $query = "UPDATE user_chat_rel SET last_activity = " . $conn->escapeString(getMicrotime()) . " " . "WHERE user_id = " . $conn->escapeString($user_id) . " AND chat_id = " . $conn->escapeString($chat_id);
     $conn->exec($query);
 }
開發者ID:krixisLv,項目名稱:SimpleChat,代碼行數:6,代碼來源:ChatHandler.php


注:本文中的DbHandler::getConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。