Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Need this code convert to phpmyadmin sql query
Old 08-02-2008, 02:29 PM Need this code convert to phpmyadmin sql query
Average Talker

Posts: 22
Trades: 0
Query: [Select]

SHOW COLUMNS
FROM {$db_prefix}members
LIKE '$column'
Query: [Select]

SHOW COLUMNS
FROM {$db_prefix}log_activity
LIKE '$column' Query: [Select]

ALTER TABLE {$db_prefix}log_activity
ADD COLUMN $column $spec
This is what i need to finish install refferal mod for smf board.
There is also install.php but it say it could not working which showed to be true
Here is content of that install.php-
<?php
/*************************************************
REFERRALS MOD v2.0
**************************************************
INSTALL.PHP
**************************************************/

if (!defined('SMF'))
die('Hacking attempt...');

// Adds the new columns to the members table - first checks if the column exists, if it doesnt, it adds it
$newcolumns = array();
$newcolumns['referrals_no'] = array('referralsno', "mediumint(8) NOT NULL default '0'");
$newcolumns['referrals_hits'] = array('referral****s', "mediumint(10) NOT NULL default '0'");
$newcolumns['referred_by'] = array('referredby', "mediumint(8) NOT NULL default '0'");
$newcolumns['referred_on'] = array('referredon', "int(10) NOT NULL default '0'");
foreach($newcolumns as $column => $spec)
{
// Old type, so rename
$result = db_query("
SHOW COLUMNS
FROM {$db_prefix}members
LIKE '".$spec[0]."'
", __FILE__, __LINE__);

if (mysql_num_rows($result) != 0)
{
db_query("
ALTER TABLE {$db_prefix}members
CHANGE ".$spec[0]." $column ".$spec[1]."
", __FILE__, __LINE__);
}
else
{
// Check if already have the new type
$result = db_query("
SHOW COLUMNS
FROM {$db_prefix}members
LIKE '$column'
", __FILE__, __LINE__);

// No previous install so create it
if (mysql_num_rows($result) == 0)
{
db_query("
ALTER TABLE {$db_prefix}members
ADD COLUMN $column ".$spec[1]."
", __FILE__, __LINE__);
}
}

// Tidy Up
unset($column, $spec);
mysql_free_result($result);
}
// Tidy Up
unset($newcolumns);

// Adds the new columns to the log activity table - first checks if the column exists, if it doesnt, it adds it
$newcolumns = array();
$newcolumns['referrals'] = "smallint(5) NOT NULL default '0'";
foreach($newcolumns as $column => $spec)
{
$result = db_query("
SHOW COLUMNS
FROM {$db_prefix}log_activity
LIKE '$column'", __FILE__, __LINE__);

if (mysql_num_rows($result) == 0) {
db_query("
ALTER TABLE {$db_prefix}log_activity
ADD COLUMN $column $spec
", __FILE__, __LINE__);
}
// Tidy Up
unset($column, $spec);
mysql_free_result($result);
}
// Tidy Up
unset($newcolumns);
?>
JACOBKELL is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-03-2008, 10:45 AM Re: Need this code convert to phpmyadmin sql query
Average Talker

Posts: 22
Trades: 0
Nevermind i will go with another script which have normal instructions for install
JACOBKELL is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Need this code convert to phpmyadmin sql query
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10745 seconds with 12 queries