本文整理匯總了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;
}