-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when using functions in Where clauses #59
Comments
Hello, By chance I have just updated the module for my site (deleting then reinstalling all the composer modules I use, including this one), and I took the opportunity to see if you could correct the problem I had raised. Unfortunately I still have the same problem: a Func object in a Where clause is not interpreted correctly. For more details, here is the error message I get: As well as the lines of code concerned by the bug (it's the initialization of hydrahon - the line that triggers the bug is indicated by the arrow in comment):
However, I come back with a new modification to propose to you so that this bug is corrected (it fixed the bug for me). In the vendor/clancats/hydrahon/src/Translator/Mysql.php file, modify the param method as follows:
Unfortunately I'm afraid I don't have time yet to propose a pull request to make my patch available in this module. Best regards, |
Hello,
First of all, congratulations for this very useful project. However, while developing an ORM based on this module, I need to use a MySQL function (and more precisely DATABASE()) in a Where clause of a query.
For the record, it's a query in the informations_schema database to get the list of columns of a table and then adapt the creation of my object accordingly.
Anyway, I logically did something like this to get my list of columns:
Except that I realized that the
new Func("DATABASE")
object was not translated into SQL, which inevitably crashes PDO when applying the parameters of the request to its execution.For all those who would have this problem, and for a future update of the module, I can propose the following correction which works for me:
I don't know if this was the best way to do it, but being able to use MySQL functions in Where clauses seems to me indispensable at least for some uses (which are probably not limited to my case alone). That's why I propose this modification. If I have time, I'll see to make a pull request, but in the meantime I gave you my solution here.
I hope this report and my proposed solution have been useful to you.
Regards,
The text was updated successfully, but these errors were encountered: