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

Комментарии • 39

  • @codestepbystep
    @codestepbystep  2 года назад +5

    Please support me by subscribe, like and comment :) thank you

  • @ektapatel_18
    @ektapatel_18 3 года назад +13

    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');

    • @FarhanKhan-on9dc
      @FarhanKhan-on9dc 2 года назад

      well i guess thats not possible, your code wont work like this

    • @FarhanKhan-on9dc
      @FarhanKhan-on9dc 2 года назад

      also if iam wrong kindly perform it and show me a screenshot

  • @ashokbishwas
    @ashokbishwas Год назад +1

    Best of the best. plz make laravel project live video.

  • @patitorodri
    @patitorodri 7 месяцев назад

    thanks man, really clear

  • @laibagillani2905
    @laibagillani2905 3 года назад +3

    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

    • @yulius4527
      @yulius4527 2 года назад

      so we can't join tables from another server ?

  • @sonukumargupta5230
    @sonukumargupta5230 Год назад

    Thank You

  • @saikumarkandikonda431
    @saikumarkandikonda431 3 года назад +1

    yes joins can be applied on different databases as well

  • @atiqulislam2626
    @atiqulislam2626 Год назад

    Yes

  • @tariqkhan5206
    @tariqkhan5206 3 года назад +3

    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();

  • @skymatrix554
    @skymatrix554 3 года назад +2

    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

  • @sandipbamaniya8559
    @sandipbamaniya8559 Год назад

    is it possible to connect live server database to local server like xampp?

  • @DevsSebas
    @DevsSebas 2 года назад

    so good bro , but i need see the Divice model please(the estructure) thansk..

  • @mohamedanwar8165
    @mohamedanwar8165 3 года назад

    Thanks

  • @hirucci8986
    @hirucci8986 3 года назад

    Thanks a lot sir

  • @ashokbishwas
    @ashokbishwas Год назад

    Interview question answer;
    Everything is possible for computer. Joining two tables of different database is also possible.

  • @hariprasadhari5045
    @hariprasadhari5045 3 года назад +2

    I think that joins can only apply on same data base

    • @hariprasadhari5045
      @hariprasadhari5045 3 года назад

      if its wrong please replay me

    • @laxmankumarrawat5690
      @laxmankumarrawat5690 3 года назад +1

      @@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();

  • @manishakoladara8013
    @manishakoladara8013 3 года назад

    is this possible second connection from another server database?

  • @syedrizvi7455
    @syedrizvi7455 3 года назад

    JOIN can apply on tables with in the same DB

  • @zoyamalik8738
    @zoyamalik8738 2 года назад

    Aik database ma agr multiple tables bna rahy hy to ksay kry gy

  • @TusharZambare
    @TusharZambare 2 года назад

    but how to join databases tables 🤔 any solution

  • @mitalgal7467
    @mitalgal7467 2 года назад

    Sir I’m not able to get data by using model

  • @eloircasas3827
    @eloircasas3827 2 года назад

    What if there is a different username on each database?

  • @enas9895
    @enas9895 2 года назад

    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

  • @dannielmagano790
    @dannielmagano790 3 года назад +1

    Hi sir. I got an Error
    SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) (SQL: select * from `users`)

  • @aliefrahman694
    @aliefrahman694 2 года назад

    How to connect both mysql and sqlite?

  • @ahangkhaneh
    @ahangkhaneh 2 года назад

    Hey Anile. Can Laravel connect to two databases in different servers?

    • @codestepbystep
      @codestepbystep  2 года назад

      Yes

    • @ahangkhaneh
      @ahangkhaneh 2 года назад +1

      @@codestepbystep So How? Would you please explain or give me a reference to learn that?

    • @prachipandey8857
      @prachipandey8857 2 года назад +1

      @@codestepbystep same question sir❓?

  • @SH-oe6vl
    @SH-oe6vl 3 года назад

    Call to undefined method Illuminate\Database\MySqlConnection::tabel()
    getting this error

  • @melaniefisher2653
    @melaniefisher2653 2 года назад

    Hello bro,can you open your telegram? I want to buy these tools.

  • @ahangkhaneh
    @ahangkhaneh 2 года назад

    Please answer my question.

  • @insightfulpod
    @insightfulpod 2 года назад

    Thank you