SQLSTATE[42S02]: Base table not found: 1146
code:
public function getUserFourElemByUid($uid)
{
print_r(self::getInstance());
$user = self::all();
if (empty($user)) {
return null;
}
return $user->toArray();
}
其中,print_r函数打印结果为:
User_DetailModel Object ( [connection] => licai_user [table] => user_detail_2 [primaryKey] => uid [incrementing] => [timestamps] => 1 [perPage:protected] => 15 [attributes:protected] => Array ( ) [original:protected] => Array ( ) [relations:protected] => Array ( ) [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [appends:protected] => Array ( ) [fillable:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) [dates:protected] => Array ( ) [casts:protected] => Array ( ) [touches:protected] => Array ( ) [observables:protected] => Array ( ) [with:protected] => Array ( ) [morphClass:protected] => [exists] => )
table字段值为user_detail_2没问题,是我想要查询的表,但是下面语句报了如下错误:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'licai_user.lc_user__detail_models' doesn't exist' in /data0/userdata/****/htdocs/finance_licai/vendor/illuminate/database/Connection.php:292 Stack trace: #0 /data0/userdata/****/htdocs/finance_licai/vendor/illuminate/database/Connection.php(292): PDO->prepare('select * from `...') #1 /data0/userdata/****/htdocs/finance_licai/vendor/illuminate/database/Connection.php(616): Illuminate\Database\Connection->Illuminate\Database\{closure}(Object(Illuminate\Database\MySqlConnection), 'select * from `...', Array) #2 /data0/userdata/****/htdocs/finance_licai/vendor/illuminate/database/Connection.php(580): Illuminate\Database\Connection->runQueryCallback('select * from `...', Array, Object(Closure)) #3 /data0/userdata/****/htdocs/finance_licai/vendor/illuminate/database/Connection.php(297): Illuminate\Database\Connection->run('select * in /data0/userdata/****/htdocs/finance_licai/vendor/illuminate/database/Connection.php on line 624
错误中提到表:licai_user.lc_user__detail_models不存在,一方面数据库中没有这个表,另一方面我想要查询的也不是这个表,而是user_detail_2表。麻烦哪位大神给解决下?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你看看你 self::all() 链接的是哪个表,打印出来看看,错误不会无故报错的,仔细检查你的代码