vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Emptying a table? (https://vborg.vbsupport.ru/showthread.php?t=127107)

Cybertims 09-20-2006 11:49 AM

Emptying a table?
 
Is there an easy way to create a link that when clicked will empty a database table??

I use the ChatBox light and want MODS to be able to prune it easily without actually having to have access to the Database.

The table is called chatboxlite_shout

Cheers in advance.

RS_Jelle 09-20-2006 12:53 PM

That's the TRUNCATE command ;)

[SQL]TRUNCATE TABLE `chatboxlite_shout`;[/SQL]

Cybertims 09-20-2006 01:03 PM

Quote:

Originally Posted by RS_Jelle
That's the TRUNCATE command ;)

[SQL]TRUNCATE TABLE `chatboxlite_shout`;[/SQL]

Cheers for that.....but to be honest it doesnt really help me too much as I have no idea how to use this to create a link that would enable my MODS to empty this said table....thanks though.

RS_Jelle 09-22-2006 03:46 PM

In vBulletin sql code it becomes:

PHP Code:

$result $db->query_write("TRUNCATE TABLE `" TABLE_PREFIX "chatboxlite_shout`"); 

You need to put it on a seperate page (for example yourmod.php?do=empty) and check for the permissions (so normal users can't use it). Those things are explained here ;)

rogersnm 09-22-2006 04:37 PM

If you want it in full do something like:
1) Make a file called chatbox.php
2) Put this as it's contents:
PHP Code:

<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''chatbox');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
if (empty($_REQUEST['do']))
{
    
$_REQUEST['do'] = 'empty';
}


if (
$_REQUEST['do'] == 'empty')
{
    if (
can_moderate())
    {
        
$vbulletin->db->query_write("TRUNCATE TABLE chatboxlite_shout");
    }
    else
    {
        
print_no_permission();
    }
}
?>

and then only people who can moderate will be able to use it.


All times are GMT. The time now is 03:00 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01819 seconds
  • Memory Usage 1,729KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete