Courses

Eloquent: The Expert Level (Laravel 9)

More Eloquent Packages You Can Explore

avatar

Hey Povilas, Great course but I have a question. Yesterday I learn about sql/MySQL store procedures. My question, procedures are helpful? You have use them? We need to use them? Why laravel don't support something like this? If yes then can you give an example how to use them.

Thanks Prodromos

avatar

In my experience, I almost never used them. I did when one project involved Microsoft SQL Server with a lot of logic of calculations inside the database.

The downside of stored procedures is then your logic is not in the code, you can't easily change it by commiting code to the repository, much harder to make changes. But, if you have some specific calculations, they are probably done faster on DB level, in some cases. So for some large projects it may make sense to move some features to stored procedures.

avatar

I thought that a real-life example might illustrate the point that Povilas has made.

Two decades ago I was responsible for fixing a broken SQL/VB6 system. The software house who had developed this system were literally incompetent. They didn't use transactions to store parent and child records atomically - instead they stored a parent record, then queried the database for the maximum auto-increment id and then created child records using that key - and of course it worked fine in a single user testing, but in a multi-user system where parent records were sometimes created simultaneously, child records started getting mixed up. Then they used a 16bit integer to hold the foreign key and couldn't work out why the system broke when the table reached 32767 records. D'oh!!

So we decided to have the system rewritten and enhanced and I specified a fuzzy search mechanism to find and prioritise data in what you might call a Venn diagram search. Objects in the database consisted of a parent item and zero or more child items, and you could search based on a different set of items and identify objects which had some commonality, ordering the results by the degree of commonality. There were also a few rules to exclude objects from the search results where items were in the object and not the search or vice versa, which complicated it a bit. Anyway, this could not be achieved using a straight-forward single SQL statement, and the data transfer of interim results would have been huge, so the only performant way to achieve this was using stored procedures and interim temporary tables, and whilst debugging these was challenging, they worked brilliantly and the users loved both the functionality and the speed.

Sadly I learned that a decade or so later they replaced the system again, and although the stored-procedure algorithms had been well documented, they failed to replicate how the old system worked and delivered a much simpler search engine which was far less effective.

avatar

Greetings Povilas, I have a question, while usingSpatie Media Library Package, adding photos is okay, but I have tried researching on how to edit photos using the same and I haven't found any. Do you have a link to an article or a YouTube video that could help me out?

Thanks

avatar

What is exactly the problem? You have a form when you upload a file, and then you delete the old file and upload a new one instead. What is the actual error you're getting here or what have you tried?

avatar

When I first upload a file, it is successfully uploading and what have you. During update, I can preview the initially uploaded file but when I click to update, I still have to select a new photo regardless.

avatar
You can use Markdown
avatar

Thanks Korop, a great tutorial

avatar
You can use Markdown
avatar

Thank you very much for so great content!

avatar
You can use Markdown
avatar
You can use Markdown