本文整理汇总了PHP中DAL::getUserById方法的典型用法代码示例。如果您正苦于以下问题:PHP DAL::getUserById方法的具体用法?PHP DAL::getUserById怎么用?PHP DAL::getUserById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DAL
的用法示例。
在下文中一共展示了DAL::getUserById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserById
public static function getUserById($user_id)
{
return DAL::getUserById($user_id);
}
示例2: getCommentsAdventure
static function getCommentsAdventure($id)
{
$req = 'SELECT * FROM comment WHERE adventure_id=?';
$param = array(0 => array($id, PDO::PARAM_INT));
$res = DB::getInstance()->prepareAndExecuteQueryWithResult($req, $param);
$comments = array();
foreach ($res as $data) {
$text = $data["content"];
$user = DAL::getUserById($data["user_id"]);
$comments[] = new Comment($user->getUsername(), $text);
}
return $comments;
}
示例3: getUserAdventures
public static function getUserAdventures($user_id)
{
$adventures = DAL::getUserAdventures($user_id);
$photos = array();
$tags = array();
$comments = array();
$nAdventures = array();
$i = 0;
foreach ($adventures as $adventure) {
$nbVotes = DAL::countVotesForAdventure($adventure->getId());
$photos = DAL::getPhotosAdventure($adventure->getId());
$tags = DAL::getTagsAdventure($adventure->getId());
$comments = DAL::getCommentsAdventure($adventure->getId());
$author = DAL::getUserById($adventure->getUser_id());
$adventure->setNumberOfVotes($nbVotes);
$adventure->setTags($tags);
$adventure->setPhotos($photos);
$adventure->setComments($comments);
$adventure->setAuthor($author->getUsername());
$nAdventures[] = $adventure;
}
return $nAdventures;
}