在核心PHP和MYSQL中我的代码到目前为止
$columns=" wine_sale.code,
launch_unit - order_unit AS unit, wine_sale.price, wine_details.colour, wine_details.vintage, wine_details.grower, wine_details.name, wine_details.region, wine_details.size, wine_sale.status, wine_size.size_name, wine_sale.discount, wine_sale.OWC, wine_sale.pack_size, wine_sale.ID, wine_note.details_show ";
$tables="wine_sale
INNER JOIN wine_details ON wine_sale.code = wine_details.code
INNER JOIN wine_region ON wine_details.region = wine_region.region_name
INNER JOIN wine_size ON wine_details.size = wine_size.size_code
LEFT JOIN wine_note ON MID(wine_details.code,1,LENGTH(wine_details.code)-1) = wine_note.details_code ";
$query = "SELECT $columns FROM $tables WHERE launch_unit - order_unit>0 AND wine_sale.includewine = 1 ORDER BY wine_region.region_order,wine_details.grower,wine_details.vintage,wine_details.name,wine_details.size ";
在Zend Framework 2中,我试图在数据库表网关中编写相同的代码,我的代码到目前为止
$select->columns(array(new Expression('launch_unit - order_unit AS unit'),'code', 'launch_unit', 'order_unit', 'price','status', 'discount', 'OWC', 'pack_size', 'ID'))
->join('wine_details', 'wine_sale.code = wine_details.code',array('colour','vintage','grower','name','region','size'))
->join('wine_region', 'wine_details.region = wine_region.region_name')
->join('wine_size', 'wine_details.size = wine_size.size_code',array('size_name'))
->join('wine_note', new Expression('MID(wine_details.code,1,LENGTH(wine_details.code)-1) = wine_note.details_code'),array('details_show'),'left');
$condition = 'launch_unit - order_unit>0 '.$critere.' AND wine_sale.includewine = 1';
$select->where($condition);
$select->order('wine_region.region_order','wine_details.grower','wine_details.vintage','wine_details.name','wine_details.size');
任何人都可以建议我做错了吗?