#208·orm

使用关联,主表无法指定字段

作者: zhouyouth创建于 2021年8月18日更新于 2021年8月27日

easyswoole 框架版本号、orm 组件版本号 [Version] easyswoole 3.4.5, orm 1.4 $res = ClientDataAccountModel::create() -> alias('dataAccount') -> field('dataAccount.id') -> with('account_users') -> all(['id' => $account_id]);

// 关联模型 return $this->belongsToMany(OrganizationUserModel::class, "sk_client_data_account_users", 'data_account_id', 'data_database_uid', function ($query) { $query->fields("id, organization_id, account, status, name, phone, username"); }); 报错如下 Unknown column 'data_account_id' in 'field list' [SELECT dataAccount.id, data_account_id FROM sk_client_data_account AS dataAccount WHERE id = 1 经过排查是 abstractModel 960 行 if (!in_array($pk, $this->fields) && $this->supplyPk == true) { $this->fields[] = $pk; } 这里的问题 ## 排查情况和最小复现脚本 [Tests and Recurrence]

内容来源: easy-swoole/orm