DBQuery Syntax

Started by PoLlama, July 06, 2007, 06:35:31 PM

Previous topic - Next topic

PoLlama

I have two DB query scripts, one works but seems inefficent, one is trying to be efficient, but doesn't work.

The first one
<?php

$request 
db_query("
SHOW COLUMNS
FROM 
{$db_prefix}topics
LIKE 'show_icons'"
__FILE____LINE__);
$no_upgrade mysql_num_rows($request) > 0;
mysql_free_result($request);

if (!
$no_upgrade)
{
db_query("ALTER TABLE {$db_prefix}boards
ADD `show_icons` tinyint(4) DEFAULT '1' NOT NULL"
__FILE____LINE__);
db_query("ALTER TABLE {$db_prefix}boards
ADD `show_title` tinyint(4) DEFAULT '1' NOT NULL"
__FILE____LINE__);
db_query("ALTER TABLE {$db_prefix}boards
ADD `show_name` tinyint(4) DEFAULT '1' NOT NULL"
__FILE____LINE__);
db_query("ALTER TABLE {$db_prefix}boards
ADD `show_views` tinyint(4) DEFAULT '1' NOT NULL"
__FILE____LINE__);
db_query("ALTER TABLE {$db_prefix}boards
ADD `show_replies` tinyint(4) DEFAULT '1' NOT NULL"
__FILE____LINE__);
db_query("ALTER TABLE {$db_prefix}boards
ADD `show_last` tinyint(4) DEFAULT '1' NOT NULL"
__FILE____LINE__);
db_query("ALTER TABLE {$db_prefix}boards
ADD `show_mods` tinyint(4) DEFAULT '1' NOT NULL"
__FILE____LINE__);
}


The second one... (doesn't work)
<?php

db_query
(ALTER TABLE {$db_prefix}boards 
DROP 
`show_icons` ,
DROP `show_title` ,
DROP `show_name` ,
DROP `show_views` ,
DROP `show_replies` ,
DROP `show_last` ,
DROP `show_mods` ;)

?>


I just obviously need help on how the syntax works... I would keep testing it until Ig et it right but each test which doesn't work takes a lot of trouble to undo.

Advertisement: