catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

why data tables and field names do not used `,but use ""? #578

Closed weizengreal closed 7 years ago

weizengreal commented 7 years ago

my code: $con->debug()->select('comment',array( '[><]user'=>['user.unionid'=>'comment.unionid'], ),'*',array( 'comment.unionid'=>"$unionid", 'cid'=>$comid ));

console echo : SELECT * FROM "club_comment" INNER JOIN "club_user" ON "club_user"."unionid" = "club_user"."comment.unionid" WHERE "club_comment"."unionid" = 'oV6UzwbnhiqLe_SYmnIZm9ykCSXM' AND "cid" = '227'

sql return : 1064 - 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 '"club_comment" INNER JOIN "club_user" ON "club_user"."unionid" = "club_user"."co' at line 1

Why are data tables and field names not used "`"

turbopixel commented 7 years ago

see https://github.com/catfan/Medoo/issues/508

tannu13 commented on 14 Dec 2016
Yeah that is a drag, running it via Command Line, though you can run below command
SET SQL_MODE = ANSI_QUOTES
Think, this changes (for the session) your default quotes and the query works :)
catfan commented 7 years ago

This is the problem have been discussed too many times. Please search before adding issue.

Medoo configured using standard SQL (SQL-92) on initialization for being compatible with other database. Double quote for table and column name is a part of SQL-92 standard.