本文整理匯總了PHP中xPDO::query方法的典型用法代碼示例。如果您正苦於以下問題:PHP xPDO::query方法的具體用法?PHP xPDO::query怎麽用?PHP xPDO::query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xPDO
的用法示例。
在下文中一共展示了xPDO::query方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: readAll
/**
* Mark all posts in this thread as read
* @static
* @param xPDO $modx
* @param string $type
* @return bool
*/
public static function readAll(xPDO &$modx, $type = 'message')
{
$userId = $modx->discuss->user->get('id');
$sql = 'SELECT `disThread`.`id`
FROM ' . $modx->getTableName('disThread') . ' `disThread`
INNER JOIN ' . $modx->getTableName('disThreadUser') . ' `ThreadUser`
ON `ThreadUser`.`thread` = `disThread`.`id`
LEFT JOIN ' . $modx->getTableName('disThreadRead') . ' `ThreadRead`
ON `ThreadRead`.`thread` = `disThread`.`id`
WHERE
`ThreadUser`.`user` = ' . $userId . '
AND `ThreadRead`.`id` IS NULL
AND `private` = 1
ORDER BY `disThread`.`id` DESC';
$stmt = $modx->query($sql);
if (!$stmt) {
return false;
}
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$read = $modx->getCount('disThreadRead', array('thread' => $row['id'], 'user' => $userId));
if ($read == 0) {
$read = $modx->newObject('disThreadRead');
$read->fromArray(array('thread' => $row['id'], 'board' => 0, 'user' => $userId));
$read->save();
}
}
$stmt->closeCursor();
return true;
}