当前位置: 首页>>代码示例>>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;未经允许,请勿转载。