Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi, is it possible to access DB from service layer?

Options
UM9F81RCP
UM9F81RCP Posts: 516 🧑🏻‍🚀 - Cadet

Hi,
is it possible to access DB from service layer?

Comments

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    Yes with Propel::getConnection() . But it depends in which application your service layer runs and therefore is not a good idea to use the DB in the service.

    Service layer is meant to wrap 3rd party libraries and to implement functionality that is shared between Yves/Glue and Zed, while in the standard setup only Zed provides a DB access.

    So in general if you have a DB access that's a strong indicator that you should not put that code in the service layer but into Zed instead and call it from Yves/Glue via the Client layer through Zed Gateway Controller endpoints

  • UM9F81RCP
    UM9F81RCP Posts: 516 🧑🏻‍🚀 - Cadet
    Options

    You are right, but it is a code that I have to deal with 😅

  • UM9F81RCP
    UM9F81RCP Posts: 516 🧑🏻‍🚀 - Cadet
    Options

    thanks for the feedback

  • UM9F81RCP
    UM9F81RCP Posts: 516 🧑🏻‍🚀 - Cadet
    Options

    It turned out the business requirement did not need that exactly so we were safe this time 😄