• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

MySQL: lots of databases

SendTrash

Platinum Member
I am currently trying to modify this existing code for a web application. At first, it seems very messy to me, but one thing that is really bugging me is that it has many databases.. like lots of databases to store different categories of stuff.

In the PHP code there are numerous references to mysql_select_db(), as many as 9 times in some scripts. Now, is this common practice? The applications that I have used before with PHP/MySQL just used one database and had clearly defined tables to separate data.

Am I right to assume that the multiple calls to mysql_select_db() is a very bad design choice? Or is this another common practice to store stuff in MySQL?

BTW, does anyone know of any good MySQL forums? I will be having many questions later
 
i would think that it is uncommon to query many different databases, unless there is a good reason.
 
The only time I've ever needed to use more than one database at a time is when I was moving data between two databases.
 
Are they calling to different databases, or are they going to the same one, and making a new connection everytime they run a query?
 
Originally posted by: Beau
Are they calling to different databases, or are they going to the same one, and making a new connection everytime they run a query?

they are calling a different database everytime.

ex.

they have a database for professor records and class records. When a page needs info from on or the other it calls the mysql database select function.

The more I think about it, it is a severly wrong thing to do right? there is overhead when selecting which database to load right? But then again, isn't a call to select which database used everything a user goes to a new php script? ex. for a new query, the php code still needs to open a new connection.
 
Do you mean that there are many tables within the database or are they actually accessing many different databases?
Many tables makes sense but many databases does not.

<---- database n00b just trying to help.
 
Are you refferring to something like this?

$db = mysql_connect("$db_host",$db_uname,"$db_psswd")
or die ("Could not connect to $db_host!");
mysql_select_db("db_name",$db)
or die ("Could not find database named mydomain_rep!");
$result = mysql_query($sql)
or die( mysql_error() );




I am a PHP newbie myself so my coding is still very immature and I do include a lot of that to select a table to grab data from. I am still working on "function" creation that will forego the mysql_connect... but so far I have sucked at it.







SHUX
EDIT: fixed errors.😛
 
Shux, your code is connecting to a database called db_table. The table is specified in the query after "FROM", i.e. "SELECT something FROM sometable"
 
Back
Top