Laravel 8 tutorial - Multiple Database Connection
HTML-код
- Опубликовано: 10 сен 2024
- In this laravel 8 and laravel 9 version API tutorial, we learn how to make multiple database connections in laravel with a simple way. This video is made by anil Sidhu in the English language.
Multiple DB Connection
DB config
Make Controller and Model
Multiple DB with Query Builder
Multiple DB with Model
Interview Question
Laravel tutorial full playlist • Laravel 9 tutorial
Please support me by subscribe, like and comment :) thank you
Yes, it's possible as long as they are on the same server, for example: $result = \DB::table('db1. users') ->join('db2. users', 'db2.users.id', '=', 'db1.users.id') ->select('db1.users.id', 'db2.user.id');
well i guess thats not possible, your code wont work like this
also if iam wrong kindly perform it and show me a screenshot
Best of the best. plz make laravel project live video.
thanks man, really clear
SQL Server allows you to join tables from different databases as long as those databases are on the same server. The join syntax is the same; the only difference is that you must fully specify table names
so we can't join tables from another server ?
Thank You
yes joins can be applied on different databases as well
Yes
Yes it is possible just use the db name with both of the tables. Like:
Return Model_name::join('db1.tablename', 'db2.tablename.id', '=' ,'db1.tablename.id')
->select('tablename.*)
->get();
I am having ERP software in laravel,I have 100+database in it , each organisation have different database how to create 100+ database for ERP , any solution is having for this problem, please help me to solve this
is it possible to connect live server database to local server like xampp?
so good bro , but i need see the Divice model please(the estructure) thansk..
Thanks
Thanks a lot sir
Interview question answer;
Everything is possible for computer. Joining two tables of different database is also possible.
I think that joins can only apply on same data base
if its wrong please replay me
@@hariprasadhari5045 Yes join two table on different database
Model1::where('postID',$postID)
->join('database2.table2 as db2','Model1.id','=','db2.id')
->select(['Model1.*','db2.firstName','db2.lastName'])
->orderBy('score','desc')
->get();
is this possible second connection from another server database?
JOIN can apply on tables with in the same DB
Aik database ma agr multiple tables bna rahy hy to ksay kry gy
but how to join databases tables 🤔 any solution
Sir I’m not able to get data by using model
What if there is a different username on each database?
there are many problems
1- create one migrations table for all databases not create one for each
2- any migration for any database add it in migrations table in mysql driver example (create table students in mysql2 migration recored in migrations table in mysql not mysql2 🙃
3- if you try build relation through another table belogns to different database driver not work
4- php artisan migrate:fresh give table exisits but not drop from second database
Hi sir. I got an Error
SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) (SQL: select * from `users`)
How to connect both mysql and sqlite?
Hey Anile. Can Laravel connect to two databases in different servers?
Yes
@@codestepbystep So How? Would you please explain or give me a reference to learn that?
@@codestepbystep same question sir❓?
Call to undefined method Illuminate\Database\MySqlConnection::tabel()
getting this error
It's table not tabel
Hello bro,can you open your telegram? I want to buy these tools.
Please answer my question.
Thank you