예제 #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['goods_brief'] = trim($_POST['goods_brief']);

$data['add_time'] = time();
*/
$data = array();
$_POST['goods_weight'] *= $_POST['weight_unit'];
$goods = new GoodsModel();
$data = $goods->_facade($_POST);
//自动过滤
$data = $goods->_autoFill($data);
//自动填充
if (empty($data['goods_sn'])) {
    $data['goods_sn'] = $goods->createSn();
}
/**
 * 自动验证
 */
if (!$goods->_validate($data)) {
    echo "<script>alert('表单填写错误," . implode('', $goods->getError()) . "');history.back()</script>";
    exit;
}
/**
 * 上传图片
 */
$uptool = new UpTool();
$ori_img = $uptool->up('ori_img');
if ($ori_img) {
    $data['ori_img'] = $ori_img;