Error in Connection with two different DB

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
logeshkumartk
Forum Newbie
Posts: 2
Joined: Sun Apr 12, 2015 7:58 am

Error in Connection with two different DB

Post by logeshkumartk »

I'm working on Laravel project, when im using joins with two different database (ie) [different username and password for both the database], it throws an error stating that one database username can't be used to connect with other database. can anyone please tell me how to use two different database with joins in laravel.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Error in Connection with two different DB

Post by Christopher »

I don't know about Laravel, but you need to prefix the table names with the database names in the format dbname.tablename.
(#10850)
logeshkumartk
Forum Newbie
Posts: 2
Joined: Sun Apr 12, 2015 7:58 am

Re: Error in Connection with two different DB

Post by logeshkumartk »

even if i use db name as prefix connection error will occur because db username and password are different
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Error in Connection with two different DB

Post by requinix »

You can't use two different connections for one query. Pick one connection and do the query with that.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Error in Connection with two different DB

Post by Christopher »

Yes. And remember that the database user must have SELECT privileges for both databases.
(#10850)
Post Reply