Closed lxepoo closed 6 years ago
What error?
Same problem here. If I try use the generated sql query with quotation mark around table name. I get in error.
The "SET SQL_MODE=ANSI_QUOTES" when using MySQL appears not working because i get Syntax error and no result on my inserts.
Same problem here. I don't understand why on earth are you using the non-standard double quotes for identifiers, instead of backticks. THIS IS PLAIN WRONG. Setting SQL_MODE = ANSI_QUOTES is bad practice, and more important - on some server configurations simply doesn't work at all.
I had to manually change some code in the medoo.php file (some 'x_quote' functions) in order to fix this, but I can't be sure I won't get side effects from this change...
thx !
for closed
why did you close this?
For a long time, I have forgotten why I asked. OK, I'm already open. Hah
The old version of the SQL statement generated must be combined with "SET SQL_MODE=ANSI_QUOTES", otherwise the error will be prompted, although this is compatible with SQL to Server and Mysql, but I still hope to get a better deal, such as the delimiter as variables? Different types of separators are then used to determine the different types of separators. I am a non English speaking country developer, which is translated by Google.
Just a quick update, I've found out why (at least in my case) it didn't work. The SET SQL_MODE=ANSI_QUOTES query is running at the very beginning when the connection is made, but it's important to understand that this is a sessional variable. Sometimes, a long-running PHP script can actually make the mysql connection timeout, so if the script try to run another query after it finishes with the long-running process - the mysql server will take this as a new session and the variable will be reset to default.
There is an end to the session, once the failure to open the correct "SQL_MODE=ANSI_QUOTES SET", it is likely to be wrong. Refer to my suggestion, judge the database type, and enforce the correct symbol.
Hi :) Sorry if I intromit... i'm starting using this library in some of my projects, and I incurred in the same error in quoting things in general... I debugged and corrected it for my use case and now the (not so many) query i need, works.
I don't know about your best practice about suggest coding, if you want me to pull a request just tell me...
I don't know if this modifications can be acceptable but i just replaced the "column"
with the ` symbol (i cannot reproduce it in comments xD) in the place they fixed my queries.
Modifications in Version 1.2.1 src.zip (Pay attention the attacched file have the debug parameter set to true, before you're going crazy...)
v1.5 will output by the database default quote identifier.
WHY DID YOU CLOSE THIS TOPIC (AGAIN), if the issue is still not fixed??
Keep in mind that, this is only output for debugging the query. Medoo is actually using standard quote identifier for internal execution for all database.
@omriamos It don't need to be fixed, it's now a bug. And it also output with the database default quote identifier for debug()
.
It IS a bug, on a default server configuration, without explicitly adding SET SQL_MODE=ANSI_QUOTES to every session, MySQL will die with an error message:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"User"' at line 1
hi~
No effect, in version 1.0
so , Generated SQL statement:
error in mysql version 5.6.13
How to solve?
Thank you!