本文整理汇总了PHP中phpbb\db\driver\driver_interface::sql_build_array方法的典型用法代码示例。如果您正苦于以下问题:PHP driver_interface::sql_build_array方法的具体用法?PHP driver_interface::sql_build_array怎么用?PHP driver_interface::sql_build_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\db\driver\driver_interface
的用法示例。
在下文中一共展示了driver_interface::sql_build_array方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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)));
}
}
示例2: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->db->sql_return_on_error(true);
$languages = $this->language_helper->get_available_languages();
$installed_languages = array();
foreach ($languages as $lang_info) {
$lang_pack = array('lang_iso' => $lang_info['iso'], 'lang_dir' => $lang_info['iso'], 'lang_english_name' => htmlspecialchars($lang_info['name']), 'lang_local_name' => htmlspecialchars($lang_info['local_name'], ENT_COMPAT, 'UTF-8'), 'lang_author' => htmlspecialchars($lang_info['author'], ENT_COMPAT, 'UTF-8'));
$this->db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $this->db->sql_build_array('INSERT', $lang_pack));
$installed_languages[] = (int) $this->db->sql_nextid();
if ($this->db->get_sql_error_triggered()) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message($error['message']);
}
}
$sql = 'SELECT * FROM ' . PROFILE_FIELDS_TABLE;
$result = $this->db->sql_query($sql);
$insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE);
while ($row = $this->db->sql_fetchrow($result)) {
foreach ($installed_languages as $lang_id) {
$insert_buffer->insert(array('field_id' => $row['field_id'], 'lang_id' => $lang_id, 'lang_name' => strtoupper(substr($row['field_name'], 6)), 'lang_explain' => '', 'lang_default_value' => ''));
}
}
$this->db->sql_freeresult($result);
$insert_buffer->flush();
}
示例3: edit
/**
* Edit a comment
*
* @param array $data Data to edit
* @param int $comment_id The comment ID
* @return null
*/
public function edit($data, $comment_id)
{
$sql = 'UPDATE ' . DIR_COMMENT_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $data) . '
WHERE comment_id = ' . (int) $comment_id;
$this->db->sql_query($sql);
}
示例4: create_report
/**
* Creates a report entity in the database
*
* @param array $report_data
* @return int the ID of the created entity
*/
protected function create_report(array $report_data)
{
$sql_ary = array('reason_id' => (int) $report_data['reason_id'], 'post_id' => $report_data['post_id'], 'pm_id' => $report_data['pm_id'], 'user_id' => (int) $this->user->data['user_id'], 'user_notify' => (int) $report_data['user_notify'], 'report_closed' => 0, 'report_time' => (int) time(), 'report_text' => (string) $report_data['report_text'], 'reported_post_text' => $report_data['reported_post_text'], 'reported_post_uid' => $report_data['reported_post_uid'], 'reported_post_bitfield' => $report_data['reported_post_bitfield'], 'reported_post_enable_bbcode' => $report_data['reported_post_enable_bbcode'], 'reported_post_enable_smilies' => $report_data['reported_post_enable_smilies'], 'reported_post_enable_magic_url' => $report_data['reported_post_enable_magic_url']);
$sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
$this->db->sql_query($sql);
return $this->db->sql_nextid();
}
示例5: main
public function main()
{
$topic_id = $this->request->variable('t', 0);
$post_id = $this->request->variable('p', 0);
$forum_id = $this->request->variable('f', 0);
$mode = $this->request->variable('mode', '');
$book_submit = $this->request->variable('book', false);
$viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic." . $this->php_ext . "", "f={$forum_id}&t={$topic_id}");
$return_link = '<br /><br />' . sprintf($this->user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
$body = 'add_bookmark';
if ($mode == 'delete') {
$sql = 'DELETE FROM ' . $this->postbookmark_table . "\n\t\t\t\tWHERE user_id = {$this->user->data['user_id']}\n\t\t\t\t\tAND post_id = {$post_id}";
$this->db->sql_query($sql);
$message = $this->user->lang['POST_BOOKMARK_REMOVED'];
$this->helper->output_response($message, $return_link, $viewtopic_url);
} else {
if ($mode == 'find') {
$body = 'find_bookmark';
$this->helper->get_bookmarks($mode);
} else {
$bookmark_desc = $this->request->variable('bookmark_desc', '', true);
if ($book_submit) {
$sql = 'INSERT INTO ' . $this->postbookmark_table . ' ' . $this->db->sql_build_array('INSERT', array('user_id' => $this->user->data['user_id'], 'post_id' => $post_id, 'topic_id' => $topic_id, 'bookmark_time' => time(), 'bookmark_desc' => $bookmark_desc));
$this->db->sql_query($sql);
$message = $this->user->lang['POST_BOOKMARK_ADDED'];
$this->helper->output_response($message, $return_link, $viewtopic_url);
}
}
}
$this->template->assign_vars(array('U_POST_ACTION' => append_sid("{$this->phpbb_root_path}postbookmark", "f={$forum_id}&t={$topic_id}&p={$post_id}&mode={$mode}")));
page_header($this->user->lang['POST_BOOKMARK_ADD']);
$this->template->set_filenames(array('body' => $body . '.html'));
page_footer();
return new Response('', 200);
}
示例6: fix_tree
/**
* Fix tree.
*
* @param int $i
* @param string $pkey
* @param string $table
* @param int $parent_id
* @param array $where
* @return bool
*/
protected function fix_tree(&$i, $pkey, $table, $parent_id = 0, $where = array())
{
$changes_made = false;
$sql = 'SELECT *
FROM ' . $table . '
WHERE parent_id = ' . (int) $parent_id . (!empty($where) ? ' AND ' . implode(' AND ', $where) : '') . '
ORDER BY left_id ASC';
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result)) {
// First we update the left_id for this module
if ($row['left_id'] != $i) {
$this->db->sql_query('
UPDATE ' . $table . '
SET ' . $this->db->sql_build_array('UPDATE', array('left_id' => $i)) . "\n\t\t\t\t\tWHERE {$pkey} = {$row[$pkey]}");
$changes_made = true;
}
$i++;
// Then we go through any children and update their left/right id's
$changes_made = $this->fix_tree($i, $pkey, $table, $row[$pkey], $where) || $changes_made;
// Then we come back and update the right_id for this module
if ($row['right_id'] != $i) {
$this->db->sql_query('
UPDATE ' . $table . '
SET ' . $this->db->sql_build_array('UPDATE', array('right_id' => $i)) . "\n\t\t\t\t\tWHERE {$pkey} = {$row[$pkey]}");
$changes_made = true;
}
$i++;
}
$this->db->sql_freeresult($result);
return $changes_made;
}
示例7: track
/**
* Track an object.
*
* @param int $type Object type
* @param int $id Object id
* @param bool|int $time Optional track time to use, if none is given
* the value from time() is used.
*/
public function track($type, $id, $time = false)
{
// Ignore
$this->get_track_cookie();
// Cookie storage method
if (!$this->user->data['is_registered']) {
$this->track_cookie($type, $id, $time);
return;
}
if ($this->get_track($type, $id, true) >= ($time === false ? time() : (int) $time)) {
return;
}
$sql = 'UPDATE ' . $this->sql_table . '
SET track_time = ' . ($time === false ? time() : (int) $time) . '
WHERE track_type = ' . (int) $type . '
AND track_id = ' . (int) $id . '
AND track_user_id = ' . (int) $this->user->data['user_id'];
$this->db->sql_query($sql);
if (!$this->db->sql_affectedrows()) {
$sql_ary = array('track_type' => (int) $type, 'track_id' => (int) $id, 'track_user_id' => (int) $this->user->data['user_id'], 'track_time' => $time === false ? time() : (int) $time);
$this->db->sql_return_on_error(true);
$this->db->sql_query('INSERT INTO ' . $this->sql_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary));
$this->db->sql_return_on_error();
}
$this->store[$type][$id] = $time === false ? time() : (int) $time;
}
示例8: reset_module
/**
* Run database part for resetting a module
*
* @param \board3\portal\modules\module_interface $module Module to reset
* @param int $module_id Module ID of module
*
* @return int Number of affected rows
*/
public function reset_module($module, $module_id)
{
$sql_ary = array('module_name' => $module->get_name(), 'module_image_src' => $module->get_image(), 'module_group_ids' => '', 'module_image_height' => 16, 'module_image_width' => 16, 'module_status' => self::B3_MODULE_ENABLED);
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
WHERE module_id = ' . (int) $module_id;
$this->db->sql_query($sql);
return $this->db->sql_affectedrows();
}
示例9: save
/**
* @param int $block_id
* @return array
*/
public function save($block_id)
{
$content = $this->request->variable('content', '', true);
$cblocks = $this->_get_custom_blocks();
$sql_data = array('block_id' => $block_id, 'block_content' => $content, 'bbcode_bitfield' => '', 'bbcode_options' => 7, 'bbcode_uid' => '');
generate_text_for_storage($sql_data['block_content'], $sql_data['bbcode_uid'], $sql_data['bbcode_bitfield'], $sql_data['bbcode_options'], true, true, true);
$sql = !isset($cblocks[$block_id]) ? 'INSERT INTO ' . $this->cblocks_table . ' ' . $this->db->sql_build_array('INSERT', $sql_data) : 'UPDATE ' . $this->cblocks_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_data) . ' WHERE block_id = ' . (int) $block_id;
$this->db->sql_query($sql);
$this->cache->destroy('pt_cblocks');
return array('id' => $block_id, 'content' => $this->_get_content($sql_data), 'callback' => 'previewCustomBlock');
}
示例10: send_topic
public function send_topic()
{
if ($this->user->data['is_registered'] && $this->user->data['user_lastvisit'] == 0) {
$this->create_welcome_topic($this->user->data['user_id']);
$sql_ary = array('user_lastvisit' => $this->user->data['session_last_visit']);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $this->user->data['user_id'];
$result = $this->db->sql_query($sql);
$this->db->sql_freeresult($result);
}
}
示例11: post
/**
* Post a new message to the shoutbox.
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function post()
{
// We always disallow guests to post in the shoutbox.
if (!$this->auth->acl_get('u_shoutbox_post') || $this->user->data['user_id'] == ANONYMOUS) {
return $this->error('AJAX_SHOUTBOX_ERROR', 'AJAX_SHOUTBOX_NO_PERMISSION', 403);
}
if ($this->request->is_ajax()) {
$message = $msg = trim(utf8_normalize_nfc($this->request->variable('text_shoutbox', '', true)));
if (empty($message)) {
return $this->error('AJAX_SHOUTBOX_ERROR', 'AJAX_SHOUTBOX_MESSAGE_EMPTY', 500);
}
$uid = $bitfield = $options = '';
$allow_bbcode = $this->auth->acl_get('u_shoutbox_bbcode');
$allow_urls = $allow_smilies = true;
if (!function_exists('generate_text_for_storage')) {
include $this->root_path . 'includes/functions_content.' . $this->php_ext;
}
generate_text_for_storage($message, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
$insert = array('post_message' => $message, 'post_time' => time(), 'user_id' => $this->user->data['user_id'], 'bbcode_options' => $options, 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid);
$sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', $insert);
$this->db->sql_query($sql);
if ($this->push->canPush()) {
// User configured us to submit the shoutbox post to the iOS/Android app
$this->push->post($msg, $insert['post_time'], $this->user->data['username'], $this->db->sql_nextid());
}
return new JsonResponse(array('OK'));
} else {
return $this->error('AJAX_SHOUTBOX_ERROR', 'AJAX_SHOUTBOX_ONLY_AJAX', 500);
}
}
示例12: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->db->sql_return_on_error(true);
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_name = 'BOTS'";
$result = $this->db->sql_query($sql);
$group_id = (int) $this->db->sql_fetchfield('group_id');
$this->db->sql_freeresult($result);
if (!$group_id) {
// If we reach this point then something has gone very wrong
$this->io_handler->add_error_message('NO_GROUP');
}
foreach ($this->bot_list as $bot_name => $bot_ary) {
$user_row = array('user_type' => USER_IGNORE, 'group_id' => $group_id, 'username' => $bot_name, 'user_regdate' => time(), 'user_password' => '', 'user_colour' => '9E8DA7', 'user_email' => '', 'user_lang' => $this->install_config->get('default_lang'), 'user_style' => 1, 'user_timezone' => 'UTC', 'user_dateformat' => $this->language->lang('default_dateformat'), 'user_allow_massemail' => 0, 'user_allow_pm' => 0);
if (!function_exists('user_add')) {
include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
}
$user_id = user_add($user_row);
if (!$user_id) {
// If we can't insert this user then continue to the next one to avoid inconsistent data
$this->io_handler->add_error_message('CONV_ERROR_INSERT_BOT');
continue;
}
$sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array('bot_active' => 1, 'bot_name' => (string) $bot_name, 'user_id' => (int) $user_id, 'bot_agent' => (string) $bot_ary[0], 'bot_ip' => (string) $bot_ary[1]));
$this->db->sql_query($sql);
}
}
示例13: generate_page
/**
* @param int $user_id
* @param bool $admin
* @param bool $auto_login
* @param bool $viewonline
* @param string $redirect
*/
public function generate_page($user_id, $admin, $auto_login, $viewonline, $redirect)
{
$this->user->add_lang_ext('paul999/tfa', 'common');
$modules = $this->getModules();
/**
* @var module_interface $row
*/
foreach ($modules as $row) {
if ($row->is_usable($user_id)) {
$this->template->assign_block_vars('tfa_options', array_merge(array('ID' => $row->get_name(), 'NAME' => $this->user->lang($row->get_translatable_name()), 'U_SUBMIT_AUTH' => $this->controller_helper->route('paul999_tfa_read_controller_submit', array('user_id' => (int) $user_id, 'admin' => (int) $admin, 'auto_login' => (int) $auto_login, 'viewonline' => (int) $viewonline, 'class' => $row->get_name()))), $row->login_start($user_id)));
}
}
add_form_key('tfa_login_page');
$random = sha1(random_bytes(32));
if (!empty($this->user->data['tfa_random'])) {
throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG');
}
$sql_ary = array('tfa_random' => $random, 'tfa_uid' => $user_id);
$sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\tWHERE\n\t\t\t\tsession_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND\n\t\t\t\tsession_user_id = " . (int) $this->user->data['user_id'];
$this->db->sql_query($sql);
$this->template->assign_vars(array('REDIRECT' => $redirect, 'RANDOM' => $random));
page_header('TFA_KEY_REQUIRED');
$this->template->set_filenames(array('body' => '@paul999_tfa/authenticate_main.html'));
page_footer(false);
// Do not include cron on this page!
}
示例14: whois_online
/**
* grabs the list of the active users participating in chat
*
* @return boolean
*/
private function whois_online()
{
$check_time = time() - $this->session_time;
$sql_ary = ['username' => $this->user->data['username'], 'user_colour' => $this->user->data['user_colour'], 'user_lastupdate' => time()];
$sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " WHERE user_id = {$this->user->data['user_id']}";
$this->db->sql_query($sql);
$sql = 'DELETE FROM ' . CHAT_SESSIONS_TABLE . " WHERE user_lastupdate < {$check_time}";
$this->db->sql_query($sql);
$sql = 'SELECT *
FROM ' . CHAT_SESSIONS_TABLE . "\n\t\t\tWHERE user_lastupdate > {$check_time}\n\t\t\tORDER BY username ASC";
$result = $this->db->sql_query($sql);
$status_time = time();
while ($row = $this->db->sql_fetchrow($result)) {
if ($row['user_id'] == $this->user->data['user_id']) {
$this->last_post = $row['user_lastpost'];
$login_time = $row['user_login'];
$status_time = $this->last_post > $login_time ? $this->last_post : $login_time;
}
$status = $this->get_status($row['user_lastpost']);
if ($this->check_hidden($row['user_id']) === false) {
continue;
} else {
$this->template->assign_block_vars('whoisrow', ['USERNAME_FULL' => $this->clean_username(get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST'])), 'USER_COLOR' => $row['user_colour'], 'USER_STATUS' => $status]);
}
}
$this->db->sql_freeresult($result);
$this->template->assign_vars(['LAST_TIME' => time(), 'S_WHOISONLINE' => true]);
return false;
}
示例15: position
/**
* Set own position on map
*
* @return type
*/
public function position()
{
if ($this->user->data['user_id'] == ANONYMOUS || !$this->auth->acl_get('u_usermap_add')) {
trigger_error('NOT_AUTHORISED');
}
$data = array('user_usermap_lon' => substr($this->request->variable('lon', ''), 0, 10), 'user_usermap_lat' => substr($this->request->variable('lat', ''), 0, 10));
if (confirm_box(true)) {
if (!function_exists('validate_data')) {
include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
}
$error = validate_data($data, array('user_usermap_lon' => array('match', false, self::REGEX_LON), 'user_usermap_lat' => array('match', false, self::REGEX_LAT)));
if (sizeof($error)) {
$error = array_map(array($this->user, 'lang'), $error);
trigger_error(implode('<br>', $error));
}
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $data) . '
WHERE user_id = ' . (int) $this->user->data['user_id'];
$this->db->sql_query($sql);
trigger_error('POSITION_SET');
} else {
confirm_box(false, $this->user->lang('CONFIRM_COORDINATES_SET', $data['user_usermap_lon'], $data['user_usermap_lat']), build_hidden_fields(array('lon' => $data['user_usermap_lon'], 'lat' => $data['user_usermap_lat'])));
}
return $this->index();
}