本文整理汇总了PHP中message::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP message::getFromDB方法的具体用法?PHP message::getFromDB怎么用?PHP message::getFromDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message
的用法示例。
在下文中一共展示了message::getFromDB方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUnreadMessages
function getUnreadMessages($inUserID)
{
if (isset($_SESSION['userid'])) {
$messages = array();
$messageid;
$dbhandle = db_connect();
$stmt = $dbhandle->stmt_init();
//Get all messages from/to this user that are unread
$stmt->prepare("SELECT MessageID, Time FROM Messages WHERE SenderID=? AND ReceiverID=? AND ReadFlag=0 ORDER BY Time");
$stmt->bind_param("ii", $inUserID, $_SESSION['userid']);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($messageid, $temptime);
//Add each resulting message to the array to return
//Mark the message as read
while ($stmt->fetch()) {
$message = new message();
$message->getFromDB($messageid);
$message->markRead();
array_push($messages, $message);
}
$stmt->close();
$dbhandle->close();
return $messages;
}
}
示例2: json_encode
<?php
require_once 'message_class.php';
$out = array();
if (isset($_POST['messageid'])) {
$message = new message();
if ($message->getFromDB($_POST['messageid']) != null) {
$out['error'] = true;
$out['MsgNotFound'] = true;
} else {
if ($message->markRead() == null) {
$out['Success'] = true;
} else {
$out['error'] = true;
$out['NotMarkedRead'] = true;
}
}
} else {
$out['error'] = true;
$out['BadPostInput'] = true;
}
echo json_encode($out);