The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
multiple database connection - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.4 (https://userspice.com/forums/forumdisplay.php?fid=27) +--- Thread: multiple database connection (/showthread.php?tid=1462) |
multiple database connection - Hade - 04-30-2019 first of all thanks for this great tool, i've been planning to add user functions to my site but it was too much of a hassle, userspice just made it doable in less than a day. one thing i'm having a problem with rn is connecting to 2 different databases, i've checked the forum and found an old thread for ver4.3 about the same thing, tried that Quote:$db1 = DB::getDB(['db1name']);and this error came up Quote:SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not knowni've read around and i think there's something i'm doing wrong when using the code above. both databases are on the same server and use same user, so that's probably not the problem. one thing may be important to point out is that the code completely stops executing after the error, the rest of the page doesn't load. the page i'm using the code on is the users\account.php page, i'm trying to use an external database (different from the one used by userspice) to get and display data. RE: multiple database connection - mudmin - 04-30-2019 Do both databases have the same username and password and server location? RE: multiple database connection - Hade - 04-30-2019 (04-30-2019, 10:12 PM)mudmin Wrote: Do both databases have the same username and password and server location? thanks for the quick reply, yes they both have the same user and password and are both hosted on the localhost. RE: multiple database connection - Hade - 05-01-2019 so i just done some workaround, my project already had a database class that used the same variable and object name used in userspice database class (guessing here, not 100% sure), so i kept it, edited functions and variables names, and used it side by side with the userspice database class. now the two databases serve completely different purposes so this worked just fine for me, i only had some overlapping data between the two, but i don't think this would be a good solution for people working with more complicated databases |