Topic awaiting preservation: Mysql multiple connections pointers (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: 1393 |
posted 05-18-2006 18:45
Hey all, code: $database = new MySQLDB; (found on database.php in the login script) before and after my DB2 connection. But, because I'm just barely dabbling with classes (OOP) I'm afraid I may be missing something right in front of my face, or what I have done is in fact incorrect. Anyways, your thoughts are appreciated. |
Lunatic (VI) Inmate From: under the bed |
posted 05-18-2006 19:26
Well, my first question would be - why are you storing information that will be used for one site in multiple databases? |
Paranoid (IV) Inmate From: 1393 |
posted 05-18-2006 19:36
Yeah, I thought the same thing but the decision is not mine. |
Paranoid (IV) Inmate From: New Jersey, USA |
posted 05-19-2006 01:01
I deal with the pains of having to access multiple databases at work and it sucks... but it's a problem that was laid in place long before I got there so there's nothing I can do about it but work with them. |
Paranoid (IV) Inmate From: 1393 |
posted 05-19-2006 15:19
Same way... I'm using new constants defined on the same page and a new function: code: function showGames() { $appDB = mysql_connect(APP_DB_SERVER, APP_DB_USER, APP_DB_PASS); mysql_select_db(APP_DB_NAME, $appDB) or die("Unable to select DATABASE!"); $query = "SELECT * FROM " . TBL_GAMES . " ORDER BY 'id' DESC"; $result = mysql_query($query, $appDB); $num = mysql_numrows($result); if ($num == 0) { echo '<div><b>There are no new games at this time</b></div>'; } else { echo '<ul>'; for ($i = 0; $i < $num; $i++) { $title = mysql_result($result, $i, "title"); $description = mysql_result($result, $i, "description"); $price = mysql_result($result, $i, "price"); echo '<li><a href="index.php">' . $title . ' (' . $price . ')</a><br />' . $description . '</li>'; } echo '</ul>'; } mysql_close($appDB); }
|
Paranoid (IV) Inmate From: New Jersey, USA |
posted 05-20-2006 01:40
In looking around for a proper answer to your problem I've learned something that might be the solution to your problem and certainly deals with a problem I was having and didn't know why. |
Paranoid (IV) Inmate From: 1393 |
posted 05-20-2006 17:26
Thanks for the help... I've decided to let them know that if they want to use my services we are using a single database. (works beautifully with a single DB btw). Thanks again for your time. |