Example #1
0
$data['goods_desc'] = trim($_POST['goods_desc']);
$data['goods_weight'] = $_POST['goods_weight']*$_POST['weight_unit'];
$data['is_best'] = isset($_POST['is_best'])? 1:0;
$data['is_new'] = isset($_POST['is_new'])? 1:0;
$data['is_hot'] = isset($_POST['is_hot'])? 1:0;
$data['is_on_sale'] = isset($_POST['is_on_sale'])? 1:0;
//$data['keywords'] = trim($_POST['keywords']);
$data['goods_brief'] = trim($_POST['goods_brief']);

$data['add_time'] = time();
*/
$goods = new GoodsModel();
$data = array();
$goods->setField($goods->showField());
//自动格式化数据
$data = $goods->_facade($_POST);
$data['goods_weight'] = $_POST['goods_weight'] * $_POST['weight_unit'];
//自动填充
$data = $goods->_autofill($data);
//自动校验
if (!$goods->_validate($data)) {
    echo $goods->getErr()[0];
    exit;
}
//若没有goods_sn,自动生成
if (!$data['goods_sn']) {
    $data['goods_sn'] = $goods->snGenerator();
}
//上传图片
$updriver = new UploadHelper();
$ori_img = $updriver->doUpload('goods_img');