本文整理汇总了PHP中sql_field函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_field函数的具体用法?PHP sql_field怎么用?PHP sql_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_field函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_post_stats
function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id)
{
$sign = ($mode == 'delete') ? '- 1' : '+ 1';
$forum_update_sql = "forum_posts = forum_posts $sign";
$topic_update_sql = '';
if ($mode == 'delete') {
if ($post_data['last_post']) {
if ($post_data['first_post']) {
$forum_update_sql .= ', forum_topics = forum_topics - 1';
} else {
$topic_update_sql .= 'topic_replies = topic_replies - 1';
$sql = 'SELECT MAX(post_id) AS last_post_id
FROM _forum_posts
WHERE topic_id = ?';
if ($last_post_id = sql_field(sql_filter($sql, $topic_id), 'last_post_id', 0)) {
$topic_update_sql .= sql_filter(', topic_last_post_id = ?', $last_post_id);
}
}
if ($post_data['last_topic']) {
$sql = 'SELECT MAX(topic_id) AS last_topic_id
FROM _forum_posts
WHERE forum_id = ?';
if ($last_topic_id = sql_field(sql_filter($sql, $forum_id), 'last_topic_id', 0)) {
$forum_update_sql .= ($last_topic_id) ? ', forum_topic_post_id = ' . $last_topic_id : ', forum_last_topic_id = 0';
}
}
} else if ($post_data['first_post']) {
$sql = 'SELECT MIN(post_id) AS first_post_id
FROM _forum_posts
WHERE topic_id = ?';
if ($first_post_id = sql_field(sql_filter($sql, $topic_id), 'first_post_id', 0)) {
$topic_update_sql .= 'topic_replies = topic_replies - 1, topic_first_post_id = ' . $first_post_id;
}
} else {
$topic_update_sql .= 'topic_replies = topic_replies - 1';
}
} else if ($mode != 'poll_delete') {
$forum_update_sql .= ", forum_last_topic_id = $topic_id" . (($mode == 'newtopic') ? ", forum_topics = forum_topics $sign" : "");
$topic_update_sql = "topic_last_post_id = $post_id" . (($mode == 'reply') ? ", topic_replies = topic_replies $sign" : ", topic_first_post_id = $post_id");
} else {
$topic_update_sql .= 'topic_vote = 0';
}
$sql = 'UPDATE _forums SET ' . $forum_update_sql . '
WHERE forum_id = ' . $forum_id;
sql_query($sql);
if ($topic_update_sql != '')
{
$sql = "UPDATE _forum_topics SET
$topic_update_sql
WHERE topic_id = $topic_id";
sql_query($sql);
}
if ($mode != 'poll_delete')
{
$sql = "UPDATE _members
SET user_posts = user_posts $sign
WHERE user_id = $user_id";
sql_query($sql);
}
$current_time = time();
$minutes = date('is', $current_time);
$hour_now = $current_time - (60 * ($minutes[0] . $minutes[1])) - ($minutes[2] . $minutes[3]);
$sql = "UPDATE _site_stats
SET " . (($mode == 'newtopic' || $post_data['first_post']) ? 'new_topics = new_topics' : 'new_posts = new_posts') . $sign . '
WHERE date = ' . intval($hour_now);
sql_query($sql);
if (!sql_affectedrows()) {
$sql = 'INSERT INTO _site_stats (date, '.(($mode == 'newtopic' || $post_data['first_post']) ? 'new_topics': 'new_posts').')
VALUES (' . $hour_now . ', 1)';
sql_query($sql);
}
$sql = 'SELECT ug.user_id, g.group_id as g_id, u.user_posts, g.group_count, g.group_count_max FROM _groups g, _members u
LEFT JOIN _members_group ug ON g.group_id = ug.group_id AND ug.user_id = ?
WHERE u.user_id = ?
AND g.group_single_user = 0
AND g.group_count_enable = 1
AND g.group_moderator <> ?';
$result = sql_rowset(sql_filter($sql, $user_id, $user_id, $user_id));
foreach ($result as $group_data) {
$user_already_added = (empty($group_data['user_id'])) ? false : true;
$user_add = ($group_data['group_count'] == $group_data['user_posts'] && $user_id!=GUEST) ? true : false;
$user_remove = ($group_data['group_count'] > $group_data['user_posts'] || $group_data['group_count_max'] < $group_data['user_posts']) ? true : false;
//user join a autogroup
if ($user_add && !$user_already_added) {
$sql_insert = array(
'group_id' => $group_data['g_id'],
'user_id' => $user_id,
'user_pending' => 0
//.........这里部分代码省略.........
示例2: _home
public function _home() {
global $config, $cache;
if (!_button()) {
$sql = 'SELECT ub, name
FROM _artists
ORDER BY name';
return _rowset_style($sql, 'artists');
}
$name = request_var('name', '');
$sql = 'SELECT *
FROM _artists
WHERE name = ?';
if (!$a_data = sql_fieldrow(sql_filter($sql, $name))) {
fatal_error();
}
$sql = 'SELECT m.user_id, m.user_email
FROM _artists_auth a, _members m
WHERE a.ub = ?
AND a.user_id = m.user_id';
$result = sql_rowset(sql_filter($sql, $a_data['ub']));
$mods = w();
foreach ($result as $row) {
$mods[] = $row['user_id'];
}
if (count($mods)) {
foreach ($mods as $i => $each) {
$sql = 'SELECT COUNT(user_id) AS total
FROM _artists_auth
WHERE user_id = ?';
$total = sql_field(sql_filter($sql, $each), 'total', 0);
if ($total > 1) {
unset($mods[$i]);
}
}
}
if (count($mods)) {
$sql = 'UPDATE _members SET user_auth_control = 0
WHERE user_id IN (??)';
$d_sql[] = sql_filter($sql, _implode(',', $mods));
}
$ary_sql = array(
'DELETE FROM _artists WHERE ub = ?',
'DELETE FROM _artists_auth WHERE ub = ?',
'DELETE FROM _artists_fav WHERE ub = ?',
'DELETE FROM _artists_images WHERE ub = ?',
'DELETE FROM _artists_log WHERE ub = ?',
'DELETE FROM _artists_lyrics WHERE ub = ?',
'DELETE FROM _artists_posts WHERE post_ub = ?',
'DELETE FROM _artists_stats WHERE ub = ?',
'DELETE FROM _artists_viewers WHERE ub = ?',
'DELETE FROM _artists_voters WHERE ub = ?',
'DELETE FROM _artists_votes WHERE ub = ?',
'DELETE FROM _forum_topics WHERE topic_ub = ?',
'DELETE FROM _dl WHERE ub = ?'
);
$d_sql = sql_filter($ary_sql, $a_data['ub']);
$sql = 'SELECT topic_id
FROM _forum_topics
WHERE topic_ub = ?';
if ($topics = sql_rowset(sql_filter($sql, $a_data['ub']), false, 'topic_id')) {
$d_sql[] = sql_filter('DELETE FROM _forum_posts
WHERE topic_id IN (??)', _implode(',', $topics));
}
$sql = 'SELECT id
FROM _dl
WHERE ub = ?';
if ($downloads = sql_rowset(sql_filter($sql, $a_data['ub']), false, 'id')) {
$ary_sql = array(
'DELETE FROM _dl_fav WHERE dl_id IN (??)',
'DELETE FROM _dl_posts WHERE download_id IN (??)',
'DELETE FROM _dl_vote WHERE ud IN (??)',
'DELETE FROM _dl_voters WHERE ud IN (??)'
);
$d_sql = array_merge($d_sql, sql_filter($ary_sql, _implode(',', $downloads)));
}
if (!_rm($config['artists_path'] . $a_data['ub'])) {
_pre('Error al eliminar directorio de artista.', true);
}
sql_query($d_sql);
// Cache
$cache->delete('ub_list a_last_images');
redirect(s_link('a'));
}
示例3: sql_total
function sql_total($table)
{
return sql_field("SHOW TABLE STATUS LIKE '" . $table . "'", 'Auto_increment', 0);
}
示例4: _home
public function _home() {
global $config, $user, $comments;
$this->_artist();
if (_button()) {
$message = request_var('message', '');
$message = $comments->prepare($message);
$sql = 'UPDATE _artists SET bio = ?
WHERE ub = ?';
sql_query(sql_filter($sql, $message, $this->object['ub']));
_style('updated');
}
$sql = 'SELECT bio
FROM _artists
WHERE ub = ?';
$bio = sql_field(sql_filter($sql, $this->object['ub']), 'bio');
v_style(array(
'MESSAGE' => $bio)
);
return;
}
示例5: home
public function home()
{
global $core, $bio;
$v = $this->__(array_merge(w('a r'), _array_keys(w('s'), 0)));
if (!empty($v->a)) {
}
if (!empty($v->r)) {
$sql = 'SELECT *
FROM _objects o, _objects_type t, _bio b, _objects_rel_assoc ra, _objects_rel_type rt
WHERE t.type_alias = ?
AND rt.type_alias = ?
AND o.object_bio = b.bio_id
AND ra.assoc_object = o.object_id
AND ra.assoc_rel_type = rt.type_id
ORDER BY o.object_time
LIMIT ??, ??';
$news = sql_rowset(sql_filter($sql, 'news', $v->r, $v->s, $core->v('objects_per_page')));
$sql = 'SELECT COUNT(object_id) AS total
FROM _objects o, _objects_type t, _objects_rel_assoc ra, _objects_rel_type rt
WHERE t.type_alias = ?
AND rt.type_alias = ?
AND ra.assoc_object = o.object_id
AND ra.assoc_rel_type = rt.type_id';
$news_total = sql_field(sql_filter($sql, 'news', $v->r), 'total', 0);
} else {
$sql = 'SELECT *
FROM _objects o, _objects_type t, _bio b
WHERE t.type_alias = ?
AND o.object_type = t.type_id
AND o.object_bio = b.bio_id
ORDER BY o.object_time
LIMIT ??, ??';
$news = sql_rowset(sql_filter($sql, 'news', $v->s, $core->v('objects_per_page')));
$sql = 'SELECT COUNT(object_id) AS total
FROM _objects o, _objects_type t
WHERE t.type_alias = ?
AND o.object_type = t.type_id';
$news_total = sql_field(sql_filter($sql, 'news'), 'total', 0);
}
foreach ($news as $i => $row) {
if (!$i) {
_style('news', _pagination(_link('news'), 's:%d', $news_total + 1, $core->v('objects_per_page'), $v->s));
}
$_row = array('ID' => $row->object_id, 'BIO' => $row->object_bio, 'SUBJECT' => $row->object_subject, 'CONTENT' => _message($row->object_content), 'TIME' => $bio->format_date($row->object_time));
_style('news.row', array_merge($_row, $this->_profile($row)));
}
$sql = 'SELECT *
FROM _objects_rel_type
ORDER BY type_alias';
$rel_type = sql_rowset($sql);
foreach ($rel_type as $i => $row) {
if (!$i) {
_style('rel_type', array('NEWS_URL' => _link('news')));
}
$row->type_alias = _link('news', array('r' => $row->type_alias));
_style('rel_type.row', $row);
}
return;
}
示例6: _home
public function _home() {
global $config, $user, $cache, $upload;
if (_button()) {
$news_id = request_var('news_id', 0);
$sql = 'SELECT news_id
FROM _news
WHERE news_id = ?';
if (!sql_field(sql_filter($sql, $news_id), 'news_id', 0)) {
fatal_error();
}
$filepath_1 = $config['news_path'];
$f = $upload->process($filepath_1, 'add_image', 'jpg');
if (!sizeof($upload->error) && $f !== false) {
foreach ($f as $row) {
$xa = $upload->resize($row, $filepath_1, $filepath_1, $news_id, array(100, 75), false, false, true);
}
redirect(s_link());
}
_style('error', array(
'MESSAGE' => parse_error($upload->error))
);
}
$sql = 'SELECT *
FROM _news
ORDER BY post_time DESC';
$result = sql_rowset($sql);
foreach ($result as $row) {
_style('news_list', array(
'NEWS_ID' => $row['news_id'],
'NEWS_TITLE' => $row['post_subject'])
);
}
return;
}
示例7: _home
public function _home() {
global $config, $user, $cache;
$this->id = request_var('msg_id', 0);
$sql = 'SELECT *
FROM _members_posts
WHERE post_id = ?';
if (!$this->object = sql_fieldrow(sql_filter($sql, $this->id))) {
fatal_error();
}
$this->object = (object) $this->object;
if (!$user->is('founder') && $user->d('user_id') != $this->object->userpage_id) {
fatal_error();
}
$sql = 'SELECT username_base
FROM _members
WHERE user_id = ?';
$username_base = sql_field(sql_filter($sql, $this->object->userpage_id), 'username_base', '');
$sql = 'DELETE FROM _members_posts
WHERE post_id = ?';
sql_query(sql_filter($sql, $this->id));
$sql = 'UPDATE _members
SET userpage_posts = userpage_posts - 1
WHERE user_id = ?';
sql_query(sql_filter($sql, $this->object->userpage_id));
$user->delete_unread(UH_UPM, $this->id);
if ($this->object->post_time > points_start_date() && $this->object->post_time < 1203314400) {
//$user->points_remove(1, $this->object->poster_id);
}
return redirect(s_link('m', $username_base));
}
示例8: _home
public function _home() {
global $config, $user, $cache, $comments;
$sql = 'SELECT *
FROM _members_unread
WHERE element = ?
GROUP BY item';
$result = sql_rowset(sql_filter($sql, UH_T));
foreach ($result as $row) {
$sql2 = 'SELECT topic_id
FROM _forum_topics
WHERE topic_id = ?';
if (!sql_field(sql_filter($sql, $row['item']), 'topic_id', 0)) {
$user->delete_all_unread(UH_T, $row['item']);
}
}
_pre('Deleted', true);
return;
}
示例9: auth
public function auth() {
global $user;
if ($user->is('founder') || ($this->data['ch_founder'] == $user->d('user_id'))) {
return true;
}
//
// Check friends
//
if ($this->data['ch_auth'] == 2) {
$sql = 'SELECT *
FROM _members_friends
WHERE (user_id = ? AND buddy_id = ?)
OR (user_id = ? AND buddy_id = ?)';
if (sql_fieldrow(sql_filter($sql, $this->data['ch_founder'], $user->d('user_id'), $user->d('user_id'), $this->data['ch_founder']))) {
return true;
}
return false;
}
/*
0 - No Access
1 - Founder
2 - Member
*/
$sql = 'SELECT ch_auth
FROM _chat_auth
WHERE ch_id = ?
AND ch_user_id = ?';
if ($ch_auth = sql_field(sql_filter($sql, $this->data['ch_id'], $user->d('user_id')), 'ch_auth', 0)) {
switch ($ch_auth) {
case 0:
return false;
break;
case 1:
$this->data['is_founder'] = true;
break;
case 2:
$this->data['is_member'] = true;
break;
}
} else {
if ($this->data['ch_auth']) {
return false;
}
}
return true;
}
示例10: run
public function run() {
global $config, $auth, $user, $comments;
$topic_id = request_var('t', 0);
$post_id = request_var('p', 0);
if (!$topic_id && !$post_id) {
fatal_error();
}
//
// Get topic data
//
if ($post_id) {
$sql_from = ', _forum_posts p, _forum_posts p2, _members m ';
$sql_where = sql_filter('p.post_id = ? AND p.poster_id = m.user_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= ?', $post_id, $post_id);
$sql_count = ', p.post_text, m.username AS reply_username, COUNT(p2.post_id) AS prev_posts, p.post_deleted';
$sql_order = ' GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_locked, t.topic_replies, t.topic_time, t.topic_important, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_locked, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_announce, f.auth_pollcreate, f.auth_vote ORDER BY p.post_id ASC';
} else {
$sql_from = $sql_count = $sql_order = '';
$sql_where = sql_filter('t.topic_id = ?', $topic_id);
}
$sql = 'SELECT t.*, f.*' . $sql_count . '
FROM _forum_topics t, _forums f' . $sql_from . '
WHERE ' . $sql_where . ' AND f.forum_id = t.forum_id' . $sql_order;
if (!$topic_data = sql_fieldrow($sql)) {
fatal_error();
}
switch ($topic_data['forum_alias']) {
case 'events':
$sql = 'SELECT event_alias
FROM _events
WHERE event_topic = ?';
if ($event_alias = sql_field(sql_filter($sql, $topic_data['topic_id']), 'event_alias', '')) {
redirect(s_link('events', $event_alias));
}
break;
}
//
// Hide deleted posts
if (isset($topic_data['post_deleted']) && $topic_data['post_deleted']) {
fatal_error();
}
//
// Check mod auth
$mod_auth = $user->is('mod');
//
// Init vars
//
$forum_id = (int) $topic_data['forum_id'];
$topic_id = (int) $topic_data['topic_id'];
$topic_url = s_link('topic', $topic_id);
$reply = request_var('reply', 0);
$start = request_var('offset', 0);
$submit_reply = _button('post');
$submit_vote = _button('vote');
$post_message = '';
$post_reply_message = '';
$post_np = '';
$current_time = time();
$error = $is_auth = w();
if (!$post_id && $reply) {
$reply = 0;
}
//
// Start member auth
//
$is_auth = $auth->forum(AUTH_ALL, $forum_id, $topic_data);
if ($submit_reply || $submit_vote) {
$auth_key = ($submit_reply) ? 'auth_reply' : 'auth_vote';
if (((!$is_auth['auth_view'] || !$is_auth['auth_read'])) || !$is_auth[$auth_key]) {
if (!$user->is('member')) {
do_login();
}
$can_reply_closed = $auth->option(w('forum topics delete'));
if (!$can_reply_closed && ($topic_data['forum_locked'] || $topic_data['topic_locked'])) {
$error[] = 'TOPIC_LOCKED';
if ($submit_vote && !$topic_data['topic_vote']) {
$error[] = 'POST_HAS_NO_POLL';
}
}
if (!sizeof($error)) {
redirect($topic_url);
}
//.........这里部分代码省略.........
示例11: bio_follower
protected final function bio_follower($local, $remote = false)
{
if ($remote === false) {
global $bio;
$remote = $bio->v('bio_id');
}
$sql = 'SELECT follower_id
FROM _bio_followers
WHERE follower_local = ?
AND follower_remote = ?
AND follower_active = ?
LIMIT 1';
if (sql_field(sql_filter($sql, $local, $remote, 1), 'follower_id', 0)) {
return true;
}
return false;
}
示例12: _rate_home
public function _rate_home() {
$v = $this->__(array('img' => '', 'rec' => ''));
$v2 = w();
foreach ($v as $kv => $vv) {
$v2[$kv] = decode($vv);
}
$address_id = 0;
$sql = 'SELECT *
FROM _email
WHERE email_id = ?';
if ($email = sql_fieldrow(sql_filter($sql, $v2['img']))) {
$sql = 'SELECT address_id
FROM ??
WHERE address_id = ?';
$address_id = sql_field(sql_filter($sql, $email['email_data'], $v2['rec']), 'address_id', 0);
}
$filepath = XFS . 'space/emails/' . $v2['img'] . '.jpg';
if (!@file_exists($filepath) || !$email || !$address_id) {
header('Content-Type: text/html; charset=iso-8859-1');
header("HTTP/1.1 404 Not Found");
echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /i' . $v['img'] . '-' . $v['rec'] . '.jpg was not found on this server.</p>
</body></html> ';
exit;
}
$sql = 'UPDATE ?? SET address_viewed = ?
WHERE address_id = ?';
sql_query(sql_filter($sql, $email['email_data'], time(), $v2['rec']));
header('Content-Type: image/jpeg');
@readfile($filepath);
exit;
}
示例13: create
private function create() {
$v = _request(array('event' => 0));
if (_empty($v)) {
return;
}
$sql = 'SELECT id, event_alias
FROM _events
WHERE id = ?';
if (!$event = sql_fieldrow(sql_filter($sql, $v->event))) {
return;
}
$sql = 'SELECT ub
FROM _artists_events
WHERE a_artist = ?
AND a_event = ?';
if (sql_field(sql_filter($sql, $this->object['ub'], $v->event))) {
return;
}
$sql_insert = array(
'a_artist' => $this->object['ub'],
'a_event' => $event['id']
);
sql_insert('artists_events', $sql_insert);
return redirect(s_link('events', $event['event_alias']));
}
示例14: _panel
//.........这里部分代码省略.........
$sql_viewers2 = array(
'ub' => (int) $this->data['ub'],
'user_id' => (int) $user->d('user_id')
);
$sql = 'UPDATE _artists_viewers SET ??
WHERE ??';
sql_query(sql_filter($sql, sql_build('UPDATE', $sql_viewers), sql_build('SELECT', $sql_viewers2)));
if (!sql_affectedrows()) {
$update_views = true;
$sql_stats = array('ub' => (int) $this->data['ub'], 'date' => (int) $current_month);
sql_insert('artists_viewers', $sql_viewers + $sql_viewers2);
$sql = 'UPDATE _artists_stats SET members = members + 1
WHERE ??';
sql_query(sql_filter($sql, sql_build('SELECT', $sql_stats)));
if (!sql_affectedrows()) {
$sql_insert = array(
'members' => 1,
'guests' => 0
);
sql_insert('artists_stats', $sql_stats + $sql_insert);
}
$sql = 'SELECT user_id
FROM _artists_viewers
WHERE ub = ?
ORDER BY datetime DESC
LIMIT 10, 1';
if ($row = sql_fieldrow(sql_filter($sql, $this->data['ub']))) {
$sql = 'DELETE FROM _artists_viewers
WHERE ub = ?
AND user_id = ?';
sql_query(sql_filter($sql, $this->data['ub'], $row['user_id']));
}
}
}
$_ps = request_var('ps', 0);
if ((($this->auth['user'] && $update_views) || (!$this->auth['user'] && $this->data['layout'] == 1)) && !$_ps) {
$sql = 'UPDATE _artists SET views = views + 1
WHERE ub = ?';
sql_query(sql_filter($sql, $this->data['ub']));
$this->data['views']++;
if ((!$this->auth['user'] && $this->data['layout'] == 1) && !$_ps) {
$sql_stats = array(
'ub' => (int) $this->data['ub'],
'date' => (int) $current_month
);
$sql = 'UPDATE _artists_stats SET guests = guests + 1
WHERE ??';
sql_query(sql_filter($sql, sql_build('SELECT', $sql_stats)));
if (!sql_affectedrows()) {
$sql_insert = array(
'members' => 0,
'guests' => 1
);
sql_insert('artists_stats', $sql_stats + $sql_insert);
}
示例15: object
public function object() {
global $auth, $user, $config, $comments, $upload;
$mode = request_var('mode', '');
switch ($mode) {
case 'view':
case 'fav':
case 'rsvp':
$download_id = request_var('download_id', 0);
if (!$download_id) {
redirect(s_link('events', $this->v('event_alias')));
}
switch ($mode) {
case 'view':
$sql = 'SELECT e.*, COUNT(e2.image) AS prev_images
FROM _events_images e, _events_images e2
WHERE e.event_id = ?
AND e.event_id = e2.event_id
AND e.image = ?
AND e2.image <= ?
GROUP BY e.image
ORDER BY e.image ASC';
$sql = sql_filter($sql, $this->v('id'), $download_id, $download_id);
break;
case 'rsvp':
$sql = '';
break;
default:
$sql = 'SELECT e2.*
FROM _events_images e2
LEFT JOIN _events e ON e.id = e2.event_id
WHERE e2.event_id = ?
AND e2.image = ?';
$sql = sql_filter($sql, $this->v('id'), $download_id);
break;
}
if (!empty($sql)) {
if (!$imagedata = sql_fieldrow($sql)) {
redirect(s_link('events', $this->v('event_alias')));
}
}
break;
}
switch ($mode) {
case 'fav':
if (!$user->is('member')) {
do_login();
}
$sql = 'SELECT *
FROM _events_fav
WHERE event_id = ?
AND image_id = ?
AND member_id = ?';
if ($row = sql_fieldrow(sql_filter($sql, $this->v('id'), $imagedata['image'], $user->d('user_id')))) {
$sql = 'UPDATE _events_fav SET fav_date = ?
WHERE event_id = ?
AND image_id = ?';
sql_query(sql_filter($sql, time(), $this->v('id'), $imagedata['image']));
} else {
$sql_insert = array(
'event_id' => (int) $this->v('id'),
'image_id' => (int) $imagedata['image'],
'member_id' => (int) $user->d('user_id'),
'fav_date' => time()
);
sql_insert('events_fav', $sql_insert);
}
redirect(s_link('events', $this->v('event_alias'), $imagedata['image'], 'view'));
break;
case 'rsvp':
$choice = array_key(array_keys(request_var('choice', array(0 => ''))), 0);
$topic_id = $this->v('event_topic');
if (!$topic_id) {
fatal_error();
}
if (!$choice) {
redirect(s_link('events', $this->v('event_alias')));
}
if (!$user->is('member')) {
do_login();
}
$sql = 'SELECT vd.vote_id
FROM _poll_options vd, _poll_results vr
WHERE vd.topic_id = ?
AND vr.vote_id = vd.vote_id
AND vr.vote_option_id = ?
GROUP BY vd.vote_id';
if (!$vote_id = sql_field(sql_filter($sql, $topic_id, $choice), 'vote_id', 0)) {
fatal_error();
//.........这里部分代码省略.........