本文整理汇总了PHP中phpbb\db\driver\driver_interface::sql_fetchfield方法的典型用法代码示例。如果您正苦于以下问题:PHP driver_interface::sql_fetchfield方法的具体用法?PHP driver_interface::sql_fetchfield怎么用?PHP driver_interface::sql_fetchfield使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\db\driver\driver_interface
的用法示例。
在下文中一共展示了driver_interface::sql_fetchfield方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_bookmarks
public function get_bookmarks($ext_mode = '', $forums = array())
{
define('POSTS_BOOKMARKS_TABLE', $this->table_prefix . 'posts_bookmarks');
$start = $this->request->variable('start', 0);
$sql = 'SELECT COUNT(post_id) as posts_count
FROM ' . POSTS_BOOKMARKS_TABLE . '
WHERE user_id = ' . $this->user->data['user_id'];
$result = $this->db->sql_query($sql);
$posts_count = (int) $this->db->sql_fetchfield('posts_count');
$this->db->sql_freeresult($result);
$sql_where = $sql_fields = '';
if ($ext_mode != 'find') {
$sql_where = 'LEFT JOIN ' . USERS_TABLE . ' u ON (p.poster_id = u.user_id)';
$sql_fields = ', p.post_time, u.user_id, u.username, u.user_colour';
}
$pagination_url = append_sid("{$this->phpbb_root_path}postbookmark", "mode=find");
$this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $posts_count, $this->config['topics_per_page'], $start);
$sql = 'SELECT b.post_id AS b_post_id, b.user_id, b.bookmark_time, b.bookmark_desc, p.post_id, p.forum_id, p.topic_id, p.poster_id, p.post_subject, t.topic_title ' . $sql_fields . '
FROM ' . POSTS_BOOKMARKS_TABLE . ' b
LEFT JOIN ' . POSTS_TABLE . ' p ON( b.post_id = p.post_id)
LEFT JOIN ' . TOPICS_TABLE . ' t ON( t.topic_id = p.topic_id)
' . $sql_where . '
WHERE b.user_id = ' . $this->user->data['user_id'] . '
ORDER BY b.bookmark_time ASC';
$result = $this->db->sql_query_limit($sql, $this->config['topics_per_page'], $start);
while ($row = $this->db->sql_fetchrow($result)) {
$topic_author = $sql_where ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : '';
$post_time = $sql_where ? $this->user->format_date($row['post_time']) : '';
// Send vars to template
$this->template->assign_block_vars('postrow', array('POST_ID' => $row['b_post_id'], 'POST_TIME' => $post_time, 'BOOKMARK_TIME' => $this->user->format_date($row['bookmark_time']), 'BOOKMARK_DESC' => $row['bookmark_desc'], 'TOPIC_AUTHOR' => $topic_author, 'POST_TITLE' => $row['post_subject'] ? $row['post_subject'] : $row['topic_title'], 'U_VIEW_POST' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "p=" . $row['post_id'] . "#p" . $row['post_id'] . ""), 'S_DELETED_TOPIC' => !$row['topic_id'] ? true : false, 'S_DELETED_POST' => !$row['post_id'] ? true : false, 'U_POST_BOOKMARK' => '[url=' . generate_board_url() . '/viewtopic.' . $this->php_ext . '?p=' . $row['post_id'] . '#p' . $row['post_id'] . ']' . ($row['post_subject'] ? $row['post_subject'] : $row['topic_title']) . '[/url]'));
}
$this->db->sql_freeresult($result);
$this->template->assign_vars(array('TOTAL_BOOKMARKS' => $this->user->lang('TOTAL_BOOKMARKS', (int) $posts_count), 'PAGE_NUMBER' => $this->pagination->on_page($posts_count, $this->config['topics_per_page'], $start)));
}
示例2: index_modify_page_title
public function index_modify_page_title($event)
{
// Count the videos ...
$sql = 'SELECT COUNT(video_id) AS total_videos
FROM ' . $this->video_table;
$result = $this->db->sql_query($sql);
$total_videos = (int) $this->db->sql_fetchfield('total_videos');
$this->db->sql_freeresult($result);
// Count the videos categories ...
$sql = 'SELECT COUNT(video_cat_id) AS total_categories
FROM ' . $this->video_cat_table . '';
$result = $this->db->sql_query($sql);
$total_categories = (int) $this->db->sql_fetchfield('total_categories');
$this->db->sql_freeresult($result);
// Count the videos views ...
$sql = 'SELECT SUM(video_views) AS total_views
FROM ' . $this->video_table;
$result = $this->db->sql_query($sql);
$total_views = (int) $this->db->sql_fetchfield('total_views');
$this->db->sql_freeresult($result);
$total_videos;
// Count the videos comments ...
$sql = 'SELECT COUNT(cmnt_id) AS total_comments
FROM ' . $this->video_cmnts_table;
$result = $this->db->sql_query($sql);
$total_comments = (int) $this->db->sql_fetchfield('total_comments');
$this->db->sql_freeresult($result);
$l_total_video_s = $total_videos == 0 ? 'TOTAL_VIDEO_ZERO' : 'TOTAL_VIDEOS_OTHER';
$l_total_category_s = $total_categories == 0 ? 'TOTAL_CATEGORY_ZERO' : 'TOTAL_CATEGORIES_OTHER';
$l_total_view_s = $total_views == 0 ? 'TOTAL_VIEW_ZERO' : 'TOTAL_VIEWS_OTHER';
$l_total_comment_s = $total_comments == 0 ? 'TOTAL_COMMENT_ZERO' : 'TOTAL_COMMENTS_OTHER';
$this->template->assign_vars(array('TOTAL_VIDEOS_INDEX' => sprintf($this->user->lang[$l_total_video_s], $total_videos), 'TOTAL_CATEGORIES' => sprintf($this->user->lang[$l_total_category_s], $total_categories), 'TOTAL_VIEWS' => sprintf($this->user->lang[$l_total_view_s], $total_views), 'TOTAL_COMMENTS' => sprintf($this->user->lang[$l_total_comment_s], $total_comments), 'S_ENABLE_VIDEO_STATICS_ON_INDEX' => $this->config['enable_video_statics_on_index']));
}
示例3: handle_downloadlog
public function handle_downloadlog()
{
if (!$this->auth->acl_get('a_')) {
trigger_error('Access Denied');
} else {
$this->user->add_lang_ext('dmzx/downloadlog', 'common');
$fileid = $this->request->variable('file', 0);
$start = $this->request->variable('start', 0);
// Pagination number from ACP
$dll = $this->config['downloadlog_value'];
// Generate pagination
$sql = 'SELECT COUNT(downloadslog_id) AS total_downloadlogs
FROM ' . $this->userdownloadslog_table . '
WHERE user_id = user_id
AND file_id = ' . $fileid;
$result = $this->db->sql_query($sql);
$total_downloadlogs = (int) $this->db->sql_fetchfield('total_downloadlogs');
$sql = 'SELECT d.user_id, d.down_date, u.user_id, u.username, u.user_colour
FROM ' . $this->userdownloadslog_table . ' d, ' . USERS_TABLE . ' u
WHERE u.user_id = d.user_id
AND file_id = ' . $fileid . '
ORDER BY d.down_date DESC';
$top_result = $this->db->sql_query_limit($sql, $dll, $start);
while ($row = $this->db->sql_fetchrow($top_result)) {
$this->template->assign_block_vars('downloaders', array('D_USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'D_TIME' => $this->user->format_date($row['down_date'])));
}
}
$pagination_url = $this->helper->route('dmzx_downloadlog_controller', array('file' => $fileid));
//Start pagination
$this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_downloadlogs, $dll, $start);
$this->template->assign_vars(array('DOWNLOADERS_USERS' => $total_downloadlogs == 1 ? $this->user->lang['DOWNLOADERS_COUNT'] : sprintf($this->user->lang['DOWNLOADERS_COUNTS'], $total_downloadlogs), 'DOWNLOADERS_VERSION' => $this->config['downloadlog_version']));
page_header('Downloaders Log', false);
$this->template->set_filenames(array('body' => 'DownloadLog.html'));
page_footer();
}
示例4: add_page_header_links
public function add_page_header_links($event)
{
if (!empty($this->config['allow_visits_counter'])) {
$this->language->add_lang('common', 'dmzx/counter');
$sql = 'SELECT COUNT(*) AS visits_counter
FROM ' . $this->visits_counter_table . '
WHERE ' . $this->db->sql_in_set('uvc_ip', $this->user->ip);
$result = $this->db->sql_query($sql);
$visits_counter = (int) $this->db->sql_fetchfield('visits_counter');
$this->db->sql_freeresult($result);
$visits = $this->config['visits_counter'];
if ($visits_counter == 0) {
$sql_ary = array('uvc_ip' => $this->user->ip, 'uvc_timestamp' => time());
$sql = 'INSERT INTO ' . $this->visits_counter_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
$this->db->sql_query($sql);
$this->config->increment('visits_counter', 1, true);
} else {
$sql_ary = array('uvc_timestamp' => time());
$sql = 'UPDATE ' . $this->visits_counter_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
WHERE ' . $this->db->sql_in_set('uvc_ip', $this->user->ip);
$this->db->sql_query($sql);
}
$timestamp = time() - 3600 * 24;
$sql_ary = array($timestamp);
$sql = 'DELETE FROM ' . $this->visits_counter_table . '
WHERE uvc_timestamp < ' . $timestamp;
$this->db->sql_query($sql);
$sql = 'SELECT COUNT(*) AS num_del
FROM ' . $this->visits_counter_table . ' ';
$result = $this->db->sql_query($sql);
$visitsok = (int) $this->db->sql_fetchfield('num_del');
$this->template->assign_vars(array('UNIQUE_VISITS_COUNTER' => $this->language->lang('UNIQUE_VISITS_COUNTER', $visitsok)));
}
}
示例5: get_max_id
/**
* {@inheritdoc}
*/
public function get_max_id()
{
$sql = 'SELECT MAX(topic_id) AS max_id FROM ' . POLL_OPTIONS_TABLE;
$result = $this->db->sql_query($sql);
$max_id = (int) $this->db->sql_fetchfield('max_id');
$this->db->sql_freeresult($result);
return $max_id;
}
示例6: get_max_id
/**
* {@inheritdoc}
*/
public function get_max_id()
{
$columns = $this->get_columns();
$sql = 'SELECT MAX(' . $columns['id'] . ') AS max_id FROM ' . $this->get_table_name();
$result = $this->db->sql_query($sql);
$max_id = (int) $this->db->sql_fetchfield('max_id');
$this->db->sql_freeresult($result);
return $max_id;
}
示例7: page_header
public function page_header($event)
{
$this->user->add_lang_ext('dmzx/totalavtiveext', 'common');
$sql = 'SELECT SUM(ext_active) AS count
FROM ' . EXT_TABLE;
$result = $this->db->sql_query($sql);
$ext_count = (int) $this->db->sql_fetchfield('count');
$this->template->assign_vars(array('TOTAL_EXT' => $this->user->lang['TOTAL_EXT'] . ' <strong>' . number_format($ext_count) . '</strong>'));
}
示例8: attachments_data
public function attachments_data($event)
{
$topic_id = $event['topic_id'];
$sql = 'SELECT COUNT(attach_id) as num_attachments
FROM ' . ATTACHMENTS_TABLE . " a\n\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\tAND a.is_orphan = 0";
$result = $this->db->sql_query($sql);
$num_attachments = $this->db->sql_fetchfield('num_attachments');
$this->db->sql_freeresult($result);
$this->template->assign_vars(array('U_ATTACHMENTS_TOPIC' => $this->helper->route("bb3mobi_attach_cat", array('t' => $topic_id)), 'TOTAL_ATTACH_TOPIC' => (int) $num_attachments));
}
示例9: get_group_count
/**
* Get number of groups, displayed on the legend
*
* @return int value of the last item displayed
*/
public function get_group_count()
{
$sql = 'SELECT group_legend
FROM ' . GROUPS_TABLE . '
ORDER BY group_legend DESC';
$result = $this->db->sql_query_limit($sql, 1);
$group_count = (int) $this->db->sql_fetchfield('group_legend');
$this->db->sql_freeresult($result);
return $group_count;
}
示例10: execute
/**
* Executes the command thumbnail:generate.
*
* Generate a thumbnail for all attachments which need one and don't have it yet.
*
* @param InputInterface $input The input stream used to get the argument and verboe option.
* @param OutputInterface $output The output stream, used for printing verbose-mode and error information.
*
* @return int 0.
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->section($this->user->lang('CLI_THUMBNAIL_GENERATING'));
$sql = 'SELECT COUNT(*) AS nb_missing_thumbnails
FROM ' . ATTACHMENTS_TABLE . '
WHERE thumbnail = 0';
$result = $this->db->sql_query($sql);
$nb_missing_thumbnails = (int) $this->db->sql_fetchfield('nb_missing_thumbnails');
$this->db->sql_freeresult($result);
if ($nb_missing_thumbnails === 0) {
$io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_GENERATE'));
return 0;
}
$extensions = $this->cache->obtain_attach_extensions(true);
$sql = 'SELECT attach_id, physical_filename, extension, real_filename, mimetype
FROM ' . ATTACHMENTS_TABLE . '
WHERE thumbnail = 0';
$result = $this->db->sql_query($sql);
if (!function_exists('create_thumbnail')) {
require $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext;
}
$progress = $this->create_progress_bar($nb_missing_thumbnails, $io, $output);
$progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATING'));
$progress->start();
$thumbnail_created = array();
while ($row = $this->db->sql_fetchrow($result)) {
if (isset($extensions[$row['extension']]['display_cat']) && $extensions[$row['extension']]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE) {
$source = $this->phpbb_root_path . 'files/' . $row['physical_filename'];
$destination = $this->phpbb_root_path . 'files/thumb_' . $row['physical_filename'];
if (create_thumbnail($source, $destination, $row['mimetype'])) {
$thumbnail_created[] = (int) $row['attach_id'];
if (count($thumbnail_created) === 250) {
$this->commit_changes($thumbnail_created);
$thumbnail_created = array();
}
$progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATED', $row['real_filename'], $row['physical_filename']));
} else {
$progress->setMessage('<info>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</info>');
}
}
$progress->advance();
}
$this->db->sql_freeresult($result);
if (!empty($thumbnail_created)) {
$this->commit_changes($thumbnail_created);
}
$progress->finish();
$io->newLine(2);
$io->success($this->user->lang('CLI_THUMBNAIL_GENERATING_DONE'));
return 0;
}
示例11: get_total
/**
* Get total.
*
* @return int
*/
public function get_total()
{
if ($this->total === null) {
$sql = 'SELECT COUNT(DISTINCT topic_id, post_user_id) AS cnt
FROM ' . $this->posts_table . '
WHERE post_approved = 1
AND post_deleted = 0';
$result = $this->db->sql_query($sql);
$this->total = (int) $this->db->sql_fetchfield('cnt', $result);
$this->db->sql_freeresult($result);
}
return $this->total;
}
示例12: switch
/**
* Return correct object for specified mode
*
* @param string $mode The feeds mode.
* @param int $forum_id Forum id specified by the script if forum feed provided.
* @param int $topic_id Topic id specified by the script if topic feed provided.
*
* @return object Returns correct feeds object for specified mode.
*/
function get_feed($mode, $forum_id, $topic_id)
{
switch ($mode) {
case 'forums':
if (!$this->config['feed_overall_forums']) {
return false;
}
return $this->container->get('feed.forums');
break;
case 'topics':
case 'topics_new':
if (!$this->config['feed_topics_new']) {
return false;
}
return $this->container->get('feed.topics');
break;
case 'topics_active':
if (!$this->config['feed_topics_active']) {
return false;
}
return $this->container->get('feed.topics_active');
break;
case 'news':
// Get at least one news forum
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0');
$result = $this->db->sql_query_limit($sql, 1, 0, 600);
$s_feed_news = (int) $this->db->sql_fetchfield('forum_id');
$this->db->sql_freeresult($result);
if (!$s_feed_news) {
return false;
}
return $this->container->get('feed.news');
break;
default:
if ($topic_id && $this->config['feed_topic']) {
return $this->container->get('feed.topic')->set_topic_id($topic_id);
} else {
if ($forum_id && $this->config['feed_forum']) {
return $this->container->get('feed.forum')->set_forum_id($forum_id);
} else {
if ($this->config['feed_overall']) {
return $this->container->get('feed.overall');
}
}
}
return false;
break;
}
}
示例13: cache_user_data
public function cache_user_data($event)
{
$cache_user_data = $event['user_cache_data'];
$sql_where = $this->auth->acl_get('u_viewonline') ? '' : 'AND session_viewonline = 1';
$sql = 'SELECT session_browser
FROM ' . SESSIONS_TABLE . '
WHERE session_user_id = ' . $event['poster_id'] . '
' . $sql_where . '
AND session_time >= ' . (time() - $this->config['load_online_time'] * 60) . '';
$result = $this->db->sql_query($sql);
if ($cache_user_data['session_browser'] = $this->db->sql_fetchfield('session_browser')) {
$event['user_cache_data'] = $cache_user_data;
}
}
示例14: check_user
/**
* Checks to see if we can use this username for a merge, based on a few factors.
*
* @param string $username - The username to check
* @param array &$errors - Errors array to work with
* @return mixed - Return the user's ID (integer) if valid, return void if there was an error
*/
private function check_user($username, &$errors, $old_user)
{
// Grabbeth the old user's ID
if (!empty($username)) {
$sql = 'SELECT user_id, user_type
FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($username)) . "'";
$result = $this->db->sql_query($sql);
$user_id = (int) $this->db->sql_fetchfield('user_id');
$user_type = (int) $this->db->sql_fetchfield('user_type');
$this->db->sql_freeresult($result);
// No such user. o_0
if (!$user_id) {
$errors[] = $this->user->lang['NO_USER'];
return;
}
} else {
$errors[] = $this->user->lang['NO_USER_SPECIFIED'];
return;
}
// Check to see if it is ourselves here
if ($user_id === (int) $this->user->data['user_id'] && $old_user) {
$errors[] = $this->user->lang['CANNOT_MERGE_SELF'];
return;
}
// Make sure we aren't messing with a founder
if ($user_type === USER_FOUNDER && $old_user && $this->user->data['user_type'] !== USER_FOUNDER) {
$errors[] = $this->user->lang['CANNOT_MERGE_FOUNDER'];
return;
}
return $user_id;
}
示例15: test_rename
public function test_rename()
{
global $table_prefix;
// uses auth, so we set up the mock/stub
// to allow reading first forum
$this->auth->expects($this->once())->method('acl_getf')->with($this->equalTo('f_read'))->willReturn(array(1 => array('f_read' => true)));
$sql_array = array('tag' => 'tag1');
$result = $this->db->sql_query('SELECT COUNT(*) as count
FROM ' . $table_prefix . tables::TAGS . '
WHERE ' . $this->db->sql_build_array('SELECT', $sql_array));
$count = $this->db->sql_fetchfield('count');
$this->assertEquals(1, $count);
$sql_array = array('tag' => 'newtagname');
$result = $this->db->sql_query('SELECT COUNT(*) as count
FROM ' . $table_prefix . tables::TAGS . '
WHERE ' . $this->db->sql_build_array('SELECT', $sql_array));
$count = $this->db->sql_fetchfield('count');
$this->assertEquals(0, $count);
$tag_id = 1;
$new_name_clean = "newtagname";
$assigned_count = $this->tags_manager->rename($tag_id, $new_name_clean);
$this->assertEquals(1, $assigned_count);
$sql_array = array('tag' => 'tag1');
$result = $this->db->sql_query('SELECT COUNT(*) as count
FROM ' . $table_prefix . tables::TAGS . '
WHERE ' . $this->db->sql_build_array('SELECT', $sql_array));
$count = $this->db->sql_fetchfield('count');
$this->assertEquals(0, $count);
$sql_array = array('tag' => 'newtagname');
$result = $this->db->sql_query('SELECT COUNT(*) as count
FROM ' . $table_prefix . tables::TAGS . '
WHERE ' . $this->db->sql_build_array('SELECT', $sql_array));
$count = $this->db->sql_fetchfield('count');
$this->assertEquals(1, $count);
}