当前位置: 首页>>代码示例>>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;未经允许,请勿转载。