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