标签:col HERE isa lis 控制器 bsp 产品 this select
thinkphp 3.2.3
如果表名中带有下划线,在分割的时候命名模型类,首字母大写,例如:order_customer_bom 为表名 .模型名为OrderCustomerBomModel
引用的时候D(‘OrderCustomerBom‘) 即可调用.
php 控制器代码如下
public function getAsinLinkPrAjax()
{
$_POST[‘asin‘]=1;
$map[‘order_customer.asin‘]=$_POST[‘asin‘];
D(‘OrderCustomerBom‘)->getAsinBomlist(123);
$u=new \Home\Model\Order_customer_bomModel();
$list=$u->getAsinBomlist();
$this->ajaxReturn($list);
}
模型代码如下
class OrderCustomerBomModel extends Model
{
//查询asin下的产品清单
public function getAsinBomlist($asin)
{
$map[‘order_customer_bom.asin‘]=$asin;
$map[‘order_customer_bom.status‘]=1;
$list=M(‘order_customer_bom‘)
->field(‘
pid,
namezh,
nameus,
thumb,
shortname
‘)
->where($map)
->join(‘LEFT JOIN product ON order_customer_bom.pid = product.id‘)
->select();
}
}
真是表明如下
CREATE TABLE `order_customer_bom` (
`id` int(11) NOT NULL,
`asin` char(32) COLLATE utf8mb4_bin NOT NULL COMMENT ‘asin‘,
`type` int(8) DEFAULT NULL COMMENT ‘类型, 类型1 为销售订单.‘,
`number` int(8) DEFAULT NULL COMMENT ‘数量‘,
`pid` int(11) DEFAULT NULL COMMENT ‘产品id‘,
`price` int(11) DEFAULT NULL COMMENT ‘单价‘,
`status` int(3) DEFAULT NULL COMMENT ‘状态 1.生效,0初始化.2删除‘,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT=‘销售清单表‘;
标签:col HERE isa lis 控制器 bsp 产品 this select
原文地址:https://www.cnblogs.com/fengxiaoyao/p/9908858.html