pjsteinfort Posted April 10, 2006 Share Posted April 10, 2006 Hi guysIm setting up a website which uses a few opensource programs to run different parts of the website, and memberships are all integrated using amember.I want to set up a module (in php) which links the contributions of individual members, so that if displaying the user's forum post or directory listing, we can link to other items on the site by that user - so pic posts, blogs, etc. Im assuming the best way to do this is to create multiple database connections, and have the username as the common link between all of them to find other contributions by that userMY QUESTION IS:Is it possible to create multiple db connections on one page? and if you can, does this then slow down the load time for that page?If anyone knows a better way to do what im trying to do, PLEASE let me know!!!pj Quote Link to comment Share on other sites More sharing options...
sdaniels Posted April 10, 2006 Share Posted April 10, 2006 [!--quoteo(post=363486:date=Apr 10 2006, 06:23 PM:name=pjsteinfort)--][div class=\'quotetop\']QUOTE(pjsteinfort @ Apr 10 2006, 06:23 PM) [snapback]363486[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi guysIm setting up a website which uses a few opensource programs to run different parts of the website, and memberships are all integrated using amember.I want to set up a module (in php) which links the contributions of individual members, so that if displaying the user's forum post or directory listing, we can link to other items on the site by that user - so pic posts, blogs, etc. Im assuming the best way to do this is to create multiple database connections, and have the username as the common link between all of them to find other contributions by that userMY QUESTION IS:Is it possible to create multiple db connections on one page? and if you can, does this then slow down the load time for that page?If anyone knows a better way to do what im trying to do, PLEASE let me know!!!pj[/quote]Im not sure is i understand your question 100%, but why not just use one database? there is no limit to how many tables you can have. If you need multiple databases you can do that if you want to. Quote Link to comment Share on other sites More sharing options...
heckenschutze Posted April 10, 2006 Share Posted April 10, 2006 You only need to make 1 connection to the MySQL host, then you can switch between each db by using mysql_select_db().[a href=\"http://php.net/mysql_select_db\" target=\"_blank\"]http://php.net/mysql_select_db[/a]An example:[code]<?php$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');if(!$link){ die('Not connected : ' . mysql_error());}$db_selected = mysql_select_db('foo', $link);if($db_selected){ // do all the queries you need from the foo database}else{ die ('Can\'t use foo : ' . mysql_error());}$db_selected = mysql_select_db('bar', $link);if($db_selected){ // do all the queries you need from the bar database }else{ die ('Can\'t use bar : ' . mysql_error());}mysql_close($link);?>[/code]HTH :). Quote Link to comment Share on other sites More sharing options...
sdaniels Posted April 10, 2006 Share Posted April 10, 2006 Im working on a guess here, but I bet you could really use this:[a href=\"http://www.webyog.com/sqlyog/index_sqlyogfree.php\" target=\"_blank\"]http://www.webyog.com/sqlyog/index_sqlyogfree.php[/a]download it and you can connect to your mysql though a GUI. Its exteremly usefull and free. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.