Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    Add More Than One Connection With Multiple Database in Magento2

    Add More Than One Connection With Multiple Database in Magento2.

    Today I am going to explain that how you can add multiple connections with multiple databases in magento 2 in this article. Suppose you have to display some data from another database instead of magento’s default database so this blog will be very helpful for you.

    At first you will need to edit app/etc/env.php, to give connection configuration for another database, like below:



    Now, you have a controller file in which you want data from custom database, then below is the code for that:



    Now when you hit above controller output will be as follows :

    data in table

    data when you print


    Hope this blog will help you to develop custom functionality in your module in a better way. Try this and if you have any query then just comment below 🙂

    . . .

    Comment (1)

    Add Your Comment

  • Aqbal
    How to geet 4 tabel data using model get value
  • Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again