vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   if table exists? (https://vborg.vbsupport.ru/showthread.php?t=100892)

pyro.699 11-15-2005 09:15 PM

if table exists?
 
whats the php code, for

'If this table exists... do this'?

Zachariah 11-15-2005 09:20 PM

CREATE TABLE IF NOT EXISTS `table_name`

IF NOT, IF

pyro.699 11-15-2005 09:31 PM

what if its not a table? i need to make a coloum in the user table

akanevsky 11-15-2005 10:00 PM

ALTER TABLE IF EXISTS `table_name` ADD `column_name`...

pyro.699 11-15-2005 10:16 PM

PHP Code:

$db->query_write(
"ALTER TABLE IF EXISTS user ADD top_game_sites INT( 1 ) NOT NULL"); 

that dosent really work...

Marco van Herwaarden 11-16-2005 05:22 AM

To test if a column exists, you cna use the following query:
[sql]SHOW COLUMNS FROM <tablename> WHERE field = '<columnname>';[/sql]
Alternative you could disable error reporting and just run the query to add the column.

pyro.699 11-16-2005 01:14 PM

could i have the exact code? i need to add a feild to the 'user' table, called 'xtreme_top_100' and thats it

Marco van Herwaarden 11-16-2005 02:08 PM

turn off error reporting:
PHP Code:

$db->reporterror false;
$db->query_write(".....");
$db->reporterror true

The other option for first testing, i think you can figure that our yourself.

pyro.699 11-16-2005 02:21 PM

lol :P

and thanks ^^


All times are GMT. The time now is 08:57 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.01001 seconds
  • Memory Usage 1,722KB
  • 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)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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