Open zhouyouth opened 3 years ago
我也遇到和你一样的问题
CREATE TABLE fa_goods
(
id
INT(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'id',
title
VARCHAR(100) NOT NULL DEFAULT '' COMMENT '名称',
sub_title
VARCHAR(50) NOT NULL DEFAULT '' COMMENT '简介',
img
VARCHAR(355) NOT NULL DEFAULT '' COMMENT '图片',
content
TEXT COMMENT '商品详情',
status
TINYINT(1) NOT NULL DEFAULT '1' COMMENT '状态?1:正常,0:下架',
is_delete
TINYINT(1) NOT NULL DEFAULT '0' COMMENT '是否删除?1:是,0:否',
delete_time
INT(11) NOT NULL DEFAULT '0' COMMENT '删除时间',
create_time
INT(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
update_time
INT(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (id
)
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='商品表'
CREATE TABLE fa_goods_category
(
goods_id
INT(11) NOT NULL DEFAULT '0' COMMENT '商品id',
category_id
INT(11) NOT NULL DEFAULT '0' COMMENT '分类id'
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT='商品分类表'
CREATE TABLE fa_goods_tag
(
goods_id
INT(11) NOT NULL DEFAULT '0' COMMENT '商品id',
tag_id
INT(11) NOT NULL DEFAULT '0' COMMENT '标签id'
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT='商品标签表'
CREATE TABLE fa_group_goods
(
id
INT(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'id',
goods_id
INT(11) NOT NULL DEFAULT '0' COMMENT '商品id',
create_time
INT(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
update_time
INT(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
member_num
INT(11) NOT NULL DEFAULT '0' COMMENT '人数',
username
VARCHAR(50) NOT NULL DEFAULT '' COMMENT '微信',
poster_img
VARCHAR(255) NOT NULL DEFAULT '' COMMENT '分海报图',
join_code
VARCHAR(50) NOT NULL DEFAULT '' COMMENT '进群码',
PRIMARY KEY (id
)
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='社群商品表'
商品模型类
class Goods extends AbstractModel { /**
获取分类 */ public function category() { return $this->hasMany(GoodsCategory::class, function (QueryBuilder $query) { }, "id", "goods_id"); }
/**
调用方法
$list = (new Goods())->alias("goods")->field("*") ->getOrderBy(["goods.id"=>"desc"]) ->withTotalCount() ->with(["tag","category"]) ->join("fa_group_goods as group_goods", "goods.id = group_goods.goods_id", "inner") ->page(1,20) ->all(["goods.status"=>1]);
好的,感谢反馈,马上处理。
好的,感谢反馈,马上处理。
好的,感谢
好的,感谢反馈,马上处理。
好的,感谢
你好,方便提供下数据吗?
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
WHEREid
= 1经过排查是 abstractModel 960 行 if (!in_array($pk, $this->fields) && $this->supplyPk == true){ $this->fields[] = $pk; } 这里的问题
排查情况和最小复现脚本 [Tests and Recurrence]
你好,请问方便提供一条测试数据及表结构,用于debug吗?
好的,感谢反馈,马上处理。
好的,感谢
你好,方便提供下数据吗?
INSERT INTO fa_goods
(title
,sub_title
,img
,content
,is_delete
,delete_time
,create_time
,update_time
,)
VALUES ('资源社群1','好资源','','
32234234234
',0,0,1629950001,1630056931);INSERT INTO fa_goods_tag
(goods_id
,tag_id
) VALUES (1,4),(1,3);
INSERT INTO fa_goods_category
(goods_id
,category_id
) VALUES (1,4),(1,3);
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
WHEREid
= 1经过排查是 abstractModel 960 行 if (!in_array($pk, $this->fields) && $this->supplyPk == true){ $this->fields[] = $pk; } 这里的问题
排查情况和最小复现脚本 [Tests and Recurrence]