code_junkie

mysql php : switching between mysql databases is slow

Nov 12th, 2011
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. function getUserarchive( $userid) {
  2. $out= "";
  3. $dbname = 'Faxarchive';
  4. $db = mysql_select_db($dbname);
  5. $sql = "select sent, received from faxarchivetable where userid = '" . $userid . "'";
  6.  
  7. if ( $rs = mysql_query($sql) {
  8. while ($row = mysql_fetch_array($rs) ) {
  9. $out = $row['sent'] . " " . $row['received'];
  10. }//end while
  11. }//end if query
  12.  
  13. return ($out);
  14. }//end function
  15.  
  16.  
  17. $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
  18.  
  19. $dbname = 'Faxusers';
  20. $db = mysql_select_db($dbname);
  21. $sql="select distinct userid from faxuserstable";
  22. if ( $rs = mysql_query($sql) {
  23. while ($row = mysql_fetch_array($rs) ) {
  24. $out = $row['userid'] . ":" . getuserarchive($row['userid']);
  25. }//end while
  26. }//end if query
  27.  
  28. SELECT sent, received
  29. FROM Faxarchive.faxarchivetable
  30. WHERE userid IN ( SELECT DISTINCT userid FROM Faxusers.faxuserstable );
Add Comment
Please, Sign In to add comment