/**
* 获取与主题关联的主题安装记录
*/
public function themeInstallation()
{
return $this->hasOne('Modules\ThemeStoreDB\Entities\ThemeInstallation', 'wp_theme_id');
}
/**
* 获取此主题安装所属 WordPress 的主题
* @return BelongsTo
*/
public function theme()
{
return $this->belongsTo('App\Models\Theme', 'wp_theme_id');
}
![获取关联属性时报错:SQLSTATE[42S02]: Base table or view not found: 1146 Table 'object_wp.wp_theme_installation' doesn't exist](https://media.shuijingwanwq.com/2022/06/1-9.png)
{
"message": "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'object_wp.wp_theme_installation' doesn't exist (SQL: select * from `wp_theme_installation` where `wp_theme_installation`.`wp_theme_id` = 105 and `wp_theme_installation`.`wp_theme_id` is not null limit 1)",
"code": "42S02",
"status_code": 500,
"debug": {
"line": 669,
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php",
"class": "Illuminate\\Database\\QueryException",
"trace": ...
}
}
/**
* 获取与主题关联的主题安装记录
*/
public function themeInstallation()
{
return $this->setConnection('mysql')->hasOne('Modules\ThemeStoreDB\Entities\ThemeInstallation', 'wp_theme_id');
}
/**
* 获取此主题安装所属 WordPress 的主题
* @return BelongsTo
*/
public function theme()
{
return $this->setConnection('wordpress')->belongsTo('App\Models\Theme', 'wp_theme_id');
}

NULL
object(Modules\ThemeStoreDB\Entities\ThemeInstallation)#3984 (26) {
["table":protected]=>
string(18) "theme_installation"
["attributes":protected]=>
array(11) {
["id"]=>
int(2)
["theme_store_theme_id"]=>
int(9)
["theme_id"]=>
string(36) "96653e3a-9f95-44dd-ade9-d928a59d0332"
["wp_theme_id"]=>
int(104)
["theme_name"]=>
string(8) "theme"
["theme_custom_name"]=>
string(8) "theme"
["role"]=>
string(11) "unpublished"
["processing"]=>
int(0)
["processing_failed"]=>
int(1)
["created_at"]=>
string(19) "2022-05-27 09:43:18"
["updated_at"]=>
string(19) "2022-05-27 09:43:22"
}
["fillable":protected]=>
array(1) {
[0]=>
string(8) "theme_id"
}
["connection":protected]=>
string(5) "mysql"
["primaryKey":protected]=>
string(2) "id"
["keyType":protected]=>
string(3) "int"
["incrementing"]=>
bool(true)
["with":protected]=>
array(0) {
}
["withCount":protected]=>
array(0) {
}
["perPage":protected]=>
int(15)
["exists"]=>
bool(true)
["wasRecentlyCreated"]=>
bool(false)
["original":protected]=>
array(11) {
["id"]=>
int(2)
["theme_store_theme_id"]=>
int(9)
["theme_id"]=>
string(36) "96653e3a-9f95-44dd-ade9-d928a59d0332"
["wp_theme_id"]=>
int(104)
["theme_name"]=>
string(8) "theme"
["theme_custom_name"]=>
string(8) "theme"
["role"]=>
string(11) "unpublished"
["processing"]=>
int(0)
["processing_failed"]=>
int(1)
["created_at"]=>
string(19) "2022-05-27 09:43:18"
["updated_at"]=>
string(19) "2022-05-27 09:43:22"
}
["changes":protected]=>
array(0) {
}
["casts":protected]=>
array(0) {
}
["dates":protected]=>
array(0) {
}
["dateFormat":protected]=>
NULL
["appends":protected]=>
array(0) {
}
["dispatchesEvents":protected]=>
array(0) {
}
["observables":protected]=>
array(0) {
}
["relations":protected]=>
array(0) {
}
["touches":protected]=>
array(0) {
}
["timestamps"]=>
bool(true)
["hidden":protected]=>
array(0) {
}
["visible":protected]=>
array(0) {
}
["guarded":protected]=>
array(1) {
[0]=>
string(1) "*"
}
}
select
*
from
`theme_installation`
where
`theme_installation`.`wp_theme_id` = 104
and `theme_installation`.`wp_theme_id` is not null
limit
1
PHP / Laravel / Yii2 老项目维护与长期技术支持
如果你的 PHP / Laravel / Yii2 项目已经上线,但遇到原开发离职、Bug 长期无人修复、接口不稳定、性能下降、代码难以接手等问题,可以联系我做一次远程技术排查。
适合以下情况:
✅ 老旧 PHP 系统无人维护
✅ Laravel / Yii2 项目 Bug 修复
✅ 后台管理系统小功能迭代
✅ RESTful API 接口排查
✅ MySQL / Redis / Nginx 性能问题
✅ 长期远程兼职维护
可先从一次小问题开始:
✅ 线上报错排查
✅ 接口异常分析
✅ 慢查询与性能瓶颈定位
✅ 代码结构初步评估
✅ 部署环境与日志检查
如需咨询,请联系我,并注明:PHP 维护咨询。
联系方式:
Telegram:@shuijingwan
微信:13980074657
邮箱:shuijingwanwq@gmail.com

发表回复