當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataBase::fetch方法代碼示例

本文整理匯總了PHP中DataBase::fetch方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataBase::fetch方法的具體用法?PHP DataBase::fetch怎麽用?PHP DataBase::fetch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataBase的用法示例。


在下文中一共展示了DataBase::fetch方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_group

/**
* 獲取指定群信息
* @UserFunction(method = GET)
* @CheckLogin
*/
function get_group(Integer $id)
{
    $db = new DataBase(DB_DNS, DB_USER, DB_PASSWORD);
    $user_id = getCurrentUserId();
    $group = $db->fetch('SELETE * FROM `group` WHERE `id` = ?', $id);
    $group['users'] = $db->fetchAll('SELECT a.`id`, a.`username`, a.`portrait` FROM `user` AS a INNER JOIN `group_user` AS b ON  b.user_id=a.id WHERE b.group_id = ?', $id);
    return $group;
}
開發者ID:huashihongfeng,項目名稱:demo-server-php,代碼行數:13,代碼來源:GroupProcess.php

示例2: delete_friend

/**
* 刪除好友數據
* @UserFunction(method = GET|POST)
* @CheckLogin
*/
function delete_friend(Integer $id)
{
    $db = new DataBase(DB_DNS, DB_USER, DB_PASSWORD);
    $my_friend_status = $db->fetch('SELECT `status` FROM `friend` WHERE `user_id` = ? AND `friend_id` = ?', getCurrentUserId(), $id);
    $other_friend_status = $db->fetch('SELECT `status` FROM `friend` WHERE `user_id` = ? AND `friend_id` = ?', $id, getCurrentUserId());
    if ($my_friend_status && $other_friend_status) {
        if ($my_friend_status['status'] == 1) {
            //我們是好友
            $db->exec('DELETE FROM `friend` WHERE `user_id`=? AND `friend_id`=?;', getCurrentUserId(), $id);
            $db->exec('UPDATE `friend` SET `status` = 5 WHERE `user_id`=? AND `friend_id`=?;', $id, getCurrentUserId());
        } else {
            if ($my_friend_status['status'] == 2) {
                // 刪除請求
                $db->exec('DELETE FROM `friend` WHERE `user_id`=? AND `friend_id`=?;', getCurrentUserId(), $id);
                $db->exec('DELETE FROM `friend` WHERE `user_id`=? AND `friend_id`=?;', $id, getCurrentUserId());
            } else {
                if ($my_friend_status['status'] == 3) {
                    // 刪除請求
                    $db->exec('DELETE FROM `friend` WHERE `user_id`=? AND `friend_id`=?;', getCurrentUserId(), $id);
                    $db->exec('UPDATE `friend` SET `status` = 4 WHERE `user_id`=? AND `friend_id`=?;', $id, getCurrentUserId());
                } else {
                    throw new ProException('unknow error', 305);
                }
            }
        }
    } else {
        if ($my_friend_status) {
            $db->exec('DELETE FROM `friend` WHERE `user_id`=? AND `friend_id`=?;', getCurrentUserId(), $id);
        } else {
            throw new ProException('unknow error', 306);
        }
    }
}
開發者ID:huashihongfeng,項目名稱:demo-server-php,代碼行數:38,代碼來源:FriendProcess.php

示例3: profile

/**
* 獲取某人用戶資料
* @UserFunction(method = GET)
* @CheckLogin
*/
function profile(Integer $id)
{
    $db = new DataBase(DB_DNS, DB_USER, DB_PASSWORD);
    $user = $db->fetch('SELECT `id`, `username`, `portrait` FROM `user` WHERE `id` = ?', $id);
    if ($user) {
        return $user;
    } else {
        throw new ProException('user not found', 109);
    }
}
開發者ID:huashihongfeng,項目名稱:demo-server-php,代碼行數:15,代碼來源:UserProcess.php


注:本文中的DataBase::fetch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。