www.GXI.co.za is new in the Joomla development game but we will be brining you many new free hacks, developments and designs shortly - This is just our first contribution, this and everything else to come will be posted on our website
www.gxi.co.za (to see what we are working on you can view our Massive development project:
www.noticeboardonline.com)
######## Solution 1: (Just cron job) ########
Example:
DB Username: username
DB Password: password
Database name: database
Host: cmysql5-1.host.com
Port: 3306
NB: change jos_ if you are using an alternative prefix e.g. joom_
Note: The info below goes into your “Command” line, you need to configure how often you want to run the cron job in the cron job settings while scheduling/setting up the cron job. For more info on setting up your cron job please contact your website host or go to our support forum:
gxi.co.za/webmaster-forum.html
// SIMPLE:
Use this if your sql host is “localhost” (default in most cases)
mysql -uusername -ppassword database -e "INSERT IGNORE INTO jos_comprofiler(id,user_id) SELECT id,id FROM jos_users";
e.g (will run every hour):
* */1 * * * mysql -uusername -ppassword database -e "INSERT IGNORE INTO jos_comprofiler(id,user_id) SELECT id,id FROM jos_users";
// ADVANCED:
Use this if your sql host is not “localhost” and you need to enter a host address and port (cmysql5-1.host.com: 3306 etc)
mysql -uusername -ppassword -hcmysql5-1.host.com -P3306 database -e "INSERT IGNORE INTO jos_comprofiler(id,user_id) SELECT id,id FROM jos_users";
e.g (will run every hour):
* */1 * * * mysql -uusername -ppassword -hcmysql5-1.host.com -P3306 database -e "INSERT IGNORE INTO jos_comprofiler(id,user_id) SELECT id,id FROM jos_users";
--------------------------------------------------------------------------
######## Solution 2: (Cron job + File) ########
Create a PHP file somewhere with the following information (be sure to correct to your database settings), when you setup you crone job ensure you include the full path i.e.
* */1 * * * php /full/path/to/script.php
The PHP file must contain:
<?php
$server = 'localhost';
$username = 'mysql_username';
$password = 'mysql_password';
$database = 'mysql_database_name';
### connects to the database, or dies with error
$connection = mysql_connect($server,$username,$password);
if (!$connection)
{
die( mysql_error() );
}
### selects the db of choice, or dies with error
$db_selection = mysql_select_db($database, $connection);
if (!$db_selection)
{
die( mysql_error() );
}
### selects all tables in the db of choice, or dies with error
$alltables = mysql_query("SHOW TABLES") or die ( mysql_error() );
### loops through all of the tables and optimizes each, or dies with error
while ( $table = mysql_fetch_array($alltables) )
{
mysql_query("INSERT IGNORE INTO jos_comprofiler(id,user_id) SELECT id,id FROM jos_users") or die( mysql_error() );
}
### closes the mysql connection
mysql_close($connection);
?>
-------------------------------------------------------------------------------
Massive development project:
www.noticeboardonline.com
GXI Solutions & Development:
www.gxi.co.za
Post edited by: gxisolutions, at: 2009/09/11 19:05