catfan / Medoo

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

Error with MySQL 5.6 #362

Closed diegonella closed 7 years ago

diegonella commented 8 years ago

From example http://medoo.in/api/select

`$db_link->debug()->select("post", [ // Here is the table relativity argument that tells the relativity between the table you want to join.

// The row author_id from table post is equal the row user_id from table account
"[>]account" => ["author_id" => "user_id"],

// The row user_id from table post is equal the row user_id from table album.
// This is a shortcut to declare the relativity if the row name are the same in both table.
"[>]album" => "user_id",

// [post.user_id is equal photo.user_id and post.avatar_id is equal photo.avatar_id]
// Like above, there are two row or more are the same in both table.
"[>]photo" => ["user_id", "avatar_id"],

// If you want to join the same table with different value,
// you have to assign the table with alias.
"[>]account (replyer)" => ["replyer_id" => "user_id"],

// You can refer the previous joined table by adding the table name before the column.
"[>]account" => ["author_id" => "user_id"],
"[>]album" => ["account.user_id" => "user_id"],

// Multiple condition
"[>]account" => [
    "author_id" => "user_id",
    "album.user_id" => "user_id"
]
], [
    "post.post_id",
    "post.title",
    "account.user_id",
    "account.city",
    "replyer.user_id",
    "replyer.city"
], [
    "post.user_id" => 100,
    "ORDER" => "post.post_id DESC",
    "LIMIT" => 50
]);`

Return Query

SELECT post"."post_id,post"."title,account"."user_id,account"."city,replyer"."user_id,replyer"."city FROM "post" LEFT JOIN "account" ON "post"."author_id" = "account"."user_id" AND "album"."user_id" = "account"."user_id" LEFT JOIN "album" ON "account"."user_id" = "album"."user_id" LEFT JOIN "photo" USING ("user_id", "avatar_id") LEFT JOIN "account" AS "replyer" ON "post"."replyer_id" = "replyer"."user_id" WHERE post"."user_id = 100 ORDER BY "post"."post_id" DESC LIMIT 50

MySQL say

Error (1064): Syntax error near 'post_id,post"."title,account"."user_id,account"."city,replyer"."user_id,replyer"' at line 1

simplicitywebdesign commented 7 years ago

I'm getting the same issue. Has anybody had any luck with this?

catfan commented 7 years ago

@simplicitywebdesign What's version you are using?

diegonella commented 7 years ago

hi guys, check my fork https://github.com/diegonella/Medoo