本文整理汇总了PHP中UserDao::getUserById方法的典型用法代码示例。如果您正苦于以下问题:PHP UserDao::getUserById方法的具体用法?PHP UserDao::getUserById怎么用?PHP UserDao::getUserById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserDao
的用法示例。
在下文中一共展示了UserDao::getUserById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBookList
/**
* 获取书籍
* 初始化方式的
*/
public function getBookList($page, $language, $word)
{
require_once '../../conndb/mysql/ConnMysqlClass.php';
require_once '../../user/dao/UserDao.php';
//定义每页10本
$pageSize = 30;
//如果是0页或者没有赋值那么默认给第一页
if ("" == $page || 0 == $page) {
$page = 1;
}
$page_start = ($page - 1) * $pageSize;
$userDao = new UserDao();
$conn = ConnMysqlClass::getConnMysql();
mysql_select_db(ConnMysqlClass::getDBName(), $conn);
$str_sql = "";
//如果language不等于空,那么就加上这个条件
if ("" != $language) {
$str_sql = "select * from stack_resource_book where resource_book_language = '{$language}' order by resource_book_id desc limit {$page_start},{$pageSize} ";
} else {
if ("" != $word) {
$str_sql = "select * from stack_resource_book where resource_book_name like '%{$word}%' order by resource_book_id desc limit {$page_start},{$pageSize} ";
} else {
$str_sql = "select * from stack_resource_book order by resource_book_id desc limit {$page_start},{$pageSize} ";
//0 1,3 4
}
}
$result = mysql_query($str_sql);
$arrBooks = array();
$var = 0;
while ($row = mysql_fetch_array($result)) {
$arrBooks[$var++] = array('page' => $page, 'resource_book_name' => $row['resource_book_name'], 'resource_book_size' => $row['resource_book_size'], 'resource_book_level' => $row['resource_book_level'], 'resource_book_review' => $row['resource_book_review'], 'resource_book_word' => $row['resource_book_word'], 'resource_book_date' => $row['resource_book_date'], 'user_name' => $userDao->getUserById($row['fk_user_id']), 'resource_book_url' => $row['resource_book_url']);
}
mysql_close($conn);
return $arrBooks;
}
示例2: getLinkList
/**
* 根据信息查询链接
*
* @param 分页页数 $page
* @param 资源类别 $category
* @param 语言类别 $language
* @param 检索关键字 $word
*/
public function getLinkList($page, $category, $language, $word)
{
require_once '../../conndb/mysql/ConnMysqlClass.php';
require_once '../../user/dao/UserDao.php';
//定义每页的条数
$pageCount = 30;
//如果是0页或者没有赋值那么默认给第一页
if ("" == $page || 0 == $page) {
$page = 1;
}
//分页数据
$page_start = ($page - 1) * $pageCount;
//根据用户id查询用户名
$userDao = new UserDao();
$conn = ConnMysqlClass::getConnMysql();
mysql_select_db(ConnMysqlClass::getDBName(), $conn);
$str_sql = "select fk_user_id,fk_category_sort_name,fk_language_sort_name,resource_link_name,resource_link_url,resource_link_content,resource_link_data,resource_link_statue from stack_resource_link where fk_category_sort_name = '{$category}' ";
$str_sql_count = "select count(resource_link_id) from stack_resource_link where fk_category_sort_name = '{$category}' ";
//组合sql语句
if ("" != $language && "" == $word) {
$str_sql .= "and fk_language_sort_name = '{$language}' ";
$str_sql_count .= "and fk_language_sort_name = '{$language}' ";
} else {
if ("" == $language && "" != $word) {
$str_sql .= "and resource_link_name like '%{$word}%' or resource_link_content like '%{$word}%' ";
$str_sql_count = "and resource_link_name like '%{$word}%' or resource_link_content like '%{$word}%' ";
} else {
if ("" != $language && "" != $word) {
$str_sql .= "and fk_language_sort_name = '{$language}' and resource_link_name like '%{$word}%' or resource_link_content like '%{$word}%' ";
$str_sql_count = "and fk_language_sort_name = '{$language}' and resource_link_name like '%{$word}%' or resource_link_content like '%{$word}%' ";
}
}
}
$str_sql .= "order by resource_link_id desc limit {$page_start},{$pageCount}";
$result = mysql_query($str_sql);
$arrLinks = array();
$var = 0;
while ($row = mysql_fetch_array($result)) {
$arrLinks[$var++] = array("fk_user_id" => $row['fk_user_id'], "user_name" => $userDao->getUserById($row['fk_user_id']), "fk_category_sort_name" => $row['fk_category_sort_name'], "fk_language_sort_name" => $row['fk_language_sort_name'], "resource_link_name" => $row['resource_link_name'], "resource_link_url" => $row['resource_link_url'], "resource_link_content" => $row['resource_link_content'], "resource_link_data" => $row['resource_link_data']);
}
//查询数量能分出来多少页
$result = mysql_query($str_sql_count);
$row = mysql_fetch_array($result);
//获得分页
$pageNum = ceil($row[0] / $pageCount);
$arrLinks['pageSum'] = strval($pageNum);
//关闭数据库
mysql_close($conn);
return $arrLinks;
}
示例3: getPicList
public function getPicList($page, $pic_type)
{
//引入数据库连接
require_once '../../conndb/mysql/ConnMysqlClass.php';
require_once '../../user/dao/UserDao.php';
//定义每页的条数
$pageCount = 10;
//如果是0页或者没有赋值那么默认给第一页
if ("" == $page || 0 == $page) {
$page = 1;
}
//分页数据
$page_start = ($page - 1) * $pageCount;
//获取数据库链接
$conn = ConnMysqlClass::getConnMysql();
mysql_select_db(ConnMysqlClass::getDBName(), $conn);
$str_sql = "select pic_id,fk_user_id,pic_name,pic_type,pic_highlight,pic_width,pic_height,pic_size,pic_up_data,pic_statue from stack_resource_pic ";
//分页查询【数量】
$str_sql_count = "select count(pic_id) from stack_resource_pic ";
if ("" != $pic_type) {
$str_sql .= "where pic_type = '{$pic_type}' ";
$str_sql_count .= "where pic_type = '{$pic_type}' ";
}
$str_sql .= "order by pic_id desc limit {$page_start},{$pageCount}";
$result = mysql_query($str_sql);
$arrPics = array();
$var = 0;
//根据用户id查询用户名
$userDao = new UserDao();
while ($row = mysql_fetch_array($result)) {
$arrPics[$var++] = array("pic_id" => $row['pic_id'], "fk_user_id" => $row['fk_user_id'], 'user_head_img_name' => $userDao->getUserHeadImgNameById($row['fk_user_id']), 'user_name' => $userDao->getUserById($row['fk_user_id']), "pic_name" => $row['pic_name'], "pic_type" => $row["pic_type"], "pic_highlight" => $row['pic_highlight'], "pic_width" => $row['pic_width'], "pic_height" => $row['pic_height'], "pic_size" => $row['pic_size'], "pic_up_data" => $row['pic_up_data'], "pic_statue" => $row['pic_statue']);
}
//查询数量能分出来多少页
$result = mysql_query($str_sql_count);
$row = mysql_fetch_array($result);
//获得分页
$pageNum = ceil($row[0] / $pageCount);
$arrPics['pageSum'] = strval($pageNum);
mysql_close($conn);
return $arrPics;
}
示例4: getCaseDiscussListById
/**
* 根据id获得评论表
*
* @param 案例id $resource_case_id
*/
public function getCaseDiscussListById($resource_case_id)
{
require_once '../../conndb/mysql/ConnMysqlClass.php';
require_once '../../user/dao/UserDao.php';
//根据用户id查询用户名
$userDao = new UserDao();
$conn = ConnMysqlClass::getConnMysql();
mysql_select_db(ConnMysqlClass::getDBName(), $conn);
$sql = "select * from stack_resource_case_discuss where fk_resource_case_id = {$resource_case_id} order by resource_case_discuss_data desc";
$result = mysql_query($sql);
$arrDiscussList = array();
$var = 0;
while ($row = mysql_fetch_array($result)) {
$arrDiscussList[$var++] = array('resource_case_discuss_id' => $row['resource_case_discuss_id'], 'fk_user_id' => $row['fk_user_id'], 'user_name' => $userDao->getUserById($row['fk_user_id']), 'user_head_img_name' => $userDao->getUserHeadImgNameById($row['fk_user_id']), 'fk_resource_case_id' => $row['fk_resource_case_id'], 'resource_case_discuss_data' => $row['resource_case_discuss_data'], 'resource_case_discuss_content' => $row['resource_case_discuss_content']);
}
return $arrDiscussList;
}