本文整理汇总了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;
}
示例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;
}
示例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">
示例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);
}