本文整理汇总了PHP中DataBase::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP DataBase::exec方法的具体用法?PHP DataBase::exec怎么用?PHP DataBase::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBase
的用法示例。
在下文中一共展示了DataBase::exec方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: quit_group
/**
* 退出群
* @UserFunction(method = GET|POST)
* @CheckLogin
*/
function quit_group(Integer $id)
{
$db = new DataBase(DB_DNS, DB_USER, DB_PASSWORD);
$user_id = getCurrentUserId();
if ($db->exec('DELETE FROM `group_user` WHERE `group_id` = ? AND `user_id` = ?', $id, $user_id) > 0) {
$db->exec('UPDATE `group` SET `number` = `number`-1 WHERE `id` = ?;', $id);
}
}
示例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: array
if ($res) {
$_RETURN['status'] = 1;
$_RETURN['data'] = $res[0];
} else {
$_RETURN['status'] = -1;
$_RETURN['errorMsg'] = 'Ошибка получения данных пользователя';
}
echo json_encode($_RETURN);
}
/**
* @method: Удаляет пользователя с данным ID
* @params: ID user
* */
if ($_a == 'deleteUser') {
$id = $_GET['id'];
$res = $Db->exec('DELETE FROM user WHERE id = ' . $Db->quote($id));
$_RETURN['status'] = $res ? 1 : -1;
echo json_encode($_RETURN);
}
/**
* @method: Сохраняет новые данные пользователя
* @params: ID user, DATA from form
* */
if ($_a == 'saveUser') {
$id = $_GET['userId'];
$data = json_decode($_GET['data']);
$data->password = md5($data->password);
$rows = array('login', 'email', 'password', 'type', 'f', 'i', 'o');
$res = $Db->update('UPDATE user SET
login = ' . $Db->quote($data->login) . ',
email = ' . $Db->quote($data->mail) . ',
示例4: update_profile
/**
* 获取某人用户资料
* @UserFunction(method = POST)
* @CheckLogin
*/
function update_profile(string $username)
{
$db = new DataBase(DB_DNS, DB_USER, DB_PASSWORD);
$db->exec('UPDATE `user` SET `username`= ? WHERE `id` = ?', $username, getCurrentUserId());
}