easy-swoole / easyswoole

swoole,easyswoole,swoole framework
https://www.easyswoole.com/
Apache License 2.0
4.74k stars 511 forks source link

orm 关联表不行,关联出来的数据为空,版本1.4.31 #440

Closed 1452479141 closed 3 years ago

1452479141 commented 3 years ago

表结构 CREATE TABLE sm_order ( id int(11) NOT NULL AUTO_INCREMENT, order_number varchar(50) NOT NULL DEFAULT '' COMMENT '订单号', device_id int(11) NOT NULL DEFAULT '0' COMMENT '设备id', sole_agent_id int(11) NOT NULL DEFAULT '0' COMMENT '独家代理id', agent_id int(11) NOT NULL DEFAULT '0' COMMENT '代理id', point_id int(11) NOT NULL DEFAULT '0' COMMENT '点位id', goods_id int(11) NOT NULL DEFAULT '0' COMMENT '商品id', plan_id int(11) DEFAULT NULL COMMENT '方案id', price decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '支付价', cost_price decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '成本价', payment_type tinyint(1) DEFAULT '1' COMMENT '支付类型:1:微信支付,2:支付宝', is_into tinyint(1) NOT NULL DEFAULT '1' COMMENT '分成成功:1:成功,0:失败', open_id varchar(32) DEFAULT NULL COMMENT '用户openID', box_num int(11) DEFAULT NULL COMMENT '格子号', status tinyint(3) NOT NULL DEFAULT '0' COMMENT '订单状态 0:未支付 ,1:已支付,2:退款,3:错误分成', try_status tinyint(1) NOT NULL DEFAULT '1' COMMENT '异常状态:1:正常,2,出货失败,3:蓝牙断开连接,4:疑识机器卡主', rem_time char(11) DEFAULT NULL COMMENT '撤除时间', create_time char(11) NOT NULL DEFAULT '' COMMENT '下单时间', update_time char(11) DEFAULT NULL COMMENT '更新时间', PRIMARY KEY (id) USING BTREE, UNIQUE KEY order_number (order_number) USING BTREE, KEY device_id (device_id) USING BTREE, KEY agent_id (agent_id) USING BTREE, KEY goods_id (goods_id) USING BTREE, KEY point_id (point_id) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COMMENT='订单表';

CREATE TABLE sm_goods ( id int(11) NOT NULL AUTO_INCREMENT, goods_name varchar(32) DEFAULT NULL COMMENT '商品名', goods_code varchar(32) DEFAULT NULL COMMENT '商品编号', low_price decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '最低价格', high_price decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '最高价格', basis_sales int(10) NOT NULL DEFAULT '0' COMMENT '基础销量', img varchar(255) DEFAULT NULL COMMENT '商品图片', intro varchar(255) DEFAULT NULL COMMENT '商品描述', type_id int(11) NOT NULL DEFAULT '1' COMMENT '商品分类ID', sort int(3) NOT NULL DEFAULT '50' COMMENT '排序', bg_color varchar(100) DEFAULT NULL COMMENT '背景色', opac_photo varchar(255) DEFAULT NULL COMMENT '透明图', detail text COMMENT '商品详情', create_time char(11) DEFAULT NULL COMMENT '添加时间', update_time char(11) DEFAULT NULL COMMENT '更新时间', PRIMARY KEY (id) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COMMENT='商品表';

Player626 commented 3 years ago

return $this->hasOne(Goods::class,null,'goods_id','id');