我看了eql的视频我发现那个是1对多的多态,而不是多对多的多态处理
{"message":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tags.tags_id' in 'field list' (SQL: select news.*, tags.tags_id as pivot_tags_id from news inner join tags on news.id = tags.tags_id where tags.tags_id = 1 and tags.tags_type = App\\Api\\V1\\Models\\News)","code":"42S22","status_code":500}
然后如果我在tags表里面加入,tags_id 和tags_type 那么打印的SQL
array:2 [
0 => array:3 [
"query" => "select * from `tags` where `tags`.`id` = ? limit 1"
"bindings" => array:1 [
0 => 2
]
"time" => 13.0
]
1 => array:3 [
"query" => "select `news`.*, `tags`.`tags_id` as `pivot_tags_id` from `news` inner join `tags` on `news`.`id` = `tags`.`tags_id` where `tags`.`tags_id` = ? and `tags`.`tags_type` = ?"
"bindings" => array:2 [
0 => 2
1 => "App\Api\V1\Models\News"
]
"time" => 3.0
]
]
但是这样的话有个问题,问题是为啥inner join的查询是
`news`.`id` = `tags`.`tags_id`
而不是
new.tags_id=tags.id