0

我不是真正的后端专家。我在这里有一些表格列,notifications这些列已被 Laravel 中的多态关系使用。

+----+------------------+----------------+
| id | sendto_type      |   sendto_id    | 
+----+------------------+----------------+
|  1 | App\User         |              1 |  
|  2 | App\User         |              2 |   
|  3 | App\Station      |              1 | 
|  4 | App\Station      |              2 | 
+----+------------------+----------------+

我想获取sendto_type具有属性“App\User”的列,它是使用 Laravel 中的多态关系制作的,并从名为users. 我也曾经sendto_id有过users表的关系。这是否可能,如果是,我将如何做到这一点。

我尝试查询 SELECT * FROM 通知 WHERE sendto_type = "App\User"。它成功但没有返回结果。请帮忙。

4

1 回答 1

1

您可能需要\在查询中转义它,因为它通常用作修饰符。另外,使用单引号而不是双引号。

WHERE sendto_type = 'App\\User'
于 2020-10-30T14:04:57.267 回答