Rotating database script

General questions relating to Joomla! 1.5 There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
dupatan
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Aug 24, 2008 6:43 pm
Contact:

Rotating database script

Postby dupatan » Tue Nov 14, 2017 1:37 pm

Hello all,
i need help with the specific db queries problem. My site is hosted on ipage which limits max questions to 70000 queries per hour per user for a database. For some reason my site goes down quite often because it goes over this limit. To put it online i manually change the db user in configuration.php file.
The solution would be the rotating mysql login script where it either chooses one of these usernames randomly to login to the database or a username in a set order to log in with an array. That way is increases my queries to 210,000 per hour.
I found such a script for drupal which switches 3 users randomly. That's what i need but for joomla. Since my knowledge in this field is very basic i'd like to ask for the advice to correct this script to use it in joomla configuration.php file.
Any help is greatly appreciated!

Here is the drupal script:

Code: Select all

$db_user_array[] = 'mysql://username1:pass23@mysql16.powweb.com/database_drupal1'; //enter 1st user name
$db_user_array[] = 'mysql://username2:pass23@mysql16.powweb.com/database_drupal1'; //enter 2nd user name
$db_user_array[] = 'mysql://username3:pass23@mysql16.powweb.com/database_drupal1'; //enter 3rd user name
$db_url = $db_user_array[ rand( 0, ( sizeof($db_user_array) -1 ) ) ];
Last edited by imanickam on Mon Mar 12, 2018 2:44 pm, edited 1 time in total.
Reason: Moved the topic from the forum General Questions/New to Joomla! 3.x to the forum General Questions/New to Joomla! 1.5

itoctopus
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4025
Joined: Mon Nov 25, 2013 4:35 pm
Location: Montreal, Canada
Contact:

Re: Rotating database script

Postby itoctopus » Tue Nov 14, 2017 2:42 pm

You will need to have a core optimization in order to do the above. In any case, the real solution to this problem is to move to a more serious host.
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter

dupatan
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Aug 24, 2008 6:43 pm
Contact:

Re: Rotating database script

Postby dupatan » Tue Nov 14, 2017 3:29 pm

So it's not possible to modify just a configuration.php file to do that?

dupatan
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Aug 24, 2008 6:43 pm
Contact:

Re: Rotating database script

Postby dupatan » Mon Mar 12, 2018 12:54 pm

For anyone who's facing same problem: here is the solution for J1.5
Core optimization is not needed! just create few users for the same database and with the same password.
In configuration.php you have to add this script after class JConfig {


function __construct()
{
$this->user = $this->getUser();
}
private function getUser()
{
$users_a = array('main_user_joomla','main_user_joomla2','main_user_joomla3');
$user_a = $users_a[array_rand($users_a)];
return $user_a;
}

dupatan
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Aug 24, 2008 6:43 pm
Contact:

Re: Rotating database script

Postby dupatan » Mon Mar 12, 2018 12:56 pm

itoctopus wrote:You will need to have a core optimization in order to do the above. In any case, the real solution to this problem is to move to a more serious host.
NOT true! See my solution above. Few lines of code in configuration.php and my problem is fixed. And i don't have to upgrade the host.

gws
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3321
Joined: Tue Aug 23, 2005 1:56 pm
Location: Kent / Sussex / Surrey border UK
Contact:

Re: Rotating database script

Postby gws » Mon Mar 12, 2018 1:39 pm

You may consider upgrading / migrating from J1.5 as it is very old and vulnerable,latest is J3.8.5


Return to “General Questions/New to Joomla! 1.5”

Who is online

Users browsing this forum: No registered users and 9 guests