public static function GetGoodsSn() { $_mu = new ModelUser('bl_goods'); $sn = substr(str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 10); // $sn = mt_rand(0,17); $res = $_mu->select(array('goods_sn'), 'goods_sn="' . $sn . '"'); if ($res) { return self::GetGoodsSn(); } else { return $sn; } }
* User: hssh_win8.1 * Date: 2015/10/5 * Time: 17:55 * file: cateedithandle.php 编辑栏目信息的处理函数 */ require_once './common/include.php'; //print_r($_POST); $cate_id = $_POST['cate_id'] + 0; $cate_name = $_POST['cate_name']; $cate_desc = $_POST['cate_desc']; $newparent_id = $_POST['parent_id'] + 0; // 实例化数据库 $mu = new ModelUser('bl_cate'); // 判断新的父栏目是否在子栏目中 如果是的话 就返回错误 $field = array('cate_id', 'parent_id'); $res = $mu->select($field, 'is_delete=0 order by cate_id'); $allChildId = ToolsInfClassify::ChildrenId($res, $cate_id); // 父栏目选取错误 if (in_array($newparent_id, $allChildId) || $newparent_id == $cate_id) { echo '2'; return; } // 改变父栏目 $arr = array('parent_id' => $newparent_id, 'cate_name' => $cate_name, 'cate_desc' => $cate_desc); $res = $mu->update($arr, 'cate_id=' . $cate_id); //echo $res; if ($res != 1) { // 编辑失败 echo '1'; return; } else {
/** * Created by PhpStorm. * User: hssh_win8.1 * Date: 2015/10/6 * Time: 22:29 * file: goodsedit.php 商品编辑页 */ require_once './common/include.php'; //实例化数据库 $mu = new ModelUser('bl_goods'); // 获得商品good_id if (!isset($_GET['goods_id']) || intval($_GET['goods_id']) < 1) { exit('商品不存在'); } $goods_id = intval($_GET['goods_id']); //获得商品信息 $sql = "select g.*,c.cate_name from bl_goods as g left join bl_cate as c on g.cate_id=c.cate_id where g.goods_id=" . $goods_id; $gi = $mu->getRow($sql); //print_r($gi); if (empty($gi)) { exit('商品不存在'); } // 更改图片的 $gi['goods_img'] = basename($gi['goods_img']); // 实例栏目数据库 $mu = new ModelUser('bl_cate'); // 获取所有栏目 $res = $mu->select(array('cate_id', 'cate_name', 'parent_id'), "is_delete=0 order by cate_id"); $catelist = ToolsInfClassify::ClassifyForOne($res); //print_r($catelist); require ROOT . 'view/admin/templates/goodsedit.html';