【发布时间】:2020-06-24 20:03:00
【问题描述】:
我的数据库名称中有三个表,sms_content、sms_content_categories 和 categories。
表 sms_content_categories 包含“categories_id”和“sms_content_id”。而类别包含“id”、“title”。我想根据“categories_id”从类别标题中获取“标题”。
基本上我在数据表中使用它并且我得到了错误。 SQLSTAT[HY00]: 一般错误: 2031 (Sql: select 'title from categories where 'id'=?)
这是我的代码:
$categoryID = SmsContentCategories::where('sms_content_id', $smsContentID)->pluck('categories_id')->toArray();
$categoryName = Category::where('id', $categoryID)->pluck('title')->toArray();
我想从类别中获取标题。
【问题讨论】:
-
dd($categoryID)以确保它包含应有的内容 -
我已经更新了我的问题