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);
?>