View Full Version : Adding Databases
Kesstryl
06-07-2012, 10:34 AM
Is there any way to add databases, not tables, but whole entire databases? My hosting company limits my database size, and this will be a problem as the site grows, even with premium service which would give me unlimited amount of databases. I suppose transfering to a more expensive server option would do the trick, but as I'm a hobbyist right now with no way to pay for that, regular hosting is all I can afford at the moment. I like my company because it is very in-expensive and a green hosting company, plus I'm familiar with their tools.
Hall of Famer
06-07-2012, 12:18 PM
umm it is possible, the database class is not singleton so you can instantiate as many database objects as you want.
Kesstryl
06-07-2012, 03:03 PM
OK thanks, sorry, I am not an expert in these things. I'll have to look up how to do this
Hall of Famer
06-08-2012, 12:30 AM
Well it is not difficult to instantiate database object, here is how the current database connection is carried out:
try{
$adopts = new Database(DBNAME, DBHOST, DBUSER, DBPASS, PREFIX);
}
catch(PDOException $pe){
die("Could not connect to database, the following error has occurred: <br><b>{$pe->getmessage()}</b>");
}
The database object accepts five arguments in its constructor, the database name, host, username, password and prefix. You can instantiate as many database objects as you wish by using this syntax below, which assumes that the database name differs but everything else remains the same
$db1 = new Database(DBNAME1, DBHOST, DBUSER, DBPASS, PREFIX);
$db2 = new Database(DBNAME2, DBHOST, DBUSER, DBPASS, PREFIX);
...
Hope this helps.
Kesstryl
06-08-2012, 06:47 AM
thanks :) I appreciate this
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.