本文整理汇总了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;
}
示例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);
}
}
}
示例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);
}
}