本文整理汇总了PHP中Helper::upload_file方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::upload_file方法的具体用法?PHP Helper::upload_file怎么用?PHP Helper::upload_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helper
的用法示例。
在下文中一共展示了Helper::upload_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionProduct_country_edit
public function actionProduct_country_edit()
{
$this->setauth();
//检查有无权限
$p_db = Yii::app()->p_db;
$id = $_GET['id'];
$country = VcosCountry::model()->findByPk($id);
if ($_POST) {
$name = isset($_POST['name']) ? $_POST['name'] : '';
$name_en = isset($_POST['name_en']) ? $_POST['name_en'] : '';
$photo = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'basic_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$photo_url = 'basic_images/' . Yii::app()->params['month'] . '/' . $photo;
$state = isset($_POST['state']) ? $_POST['state'] : '0';
// var_dump($_POST);exit;
//事务处理
$transaction = $p_db->beginTransaction();
try {
$country->country_cn_name = $name;
$country->country_en_name = $name_en;
if ($photo) {
$country->country_logo = $photo_url;
}
$country->status = $state;
$country->save();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Basic/product_country_list"));
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'));
}
}
$this->render('product_country_edit', array('country' => $country));
}
示例2: actionNav_product_category_add
public function actionNav_product_category_add()
{
$this->setauth();
//检查有无权限
$p_db = Yii::app()->p_db;
$group = new VcosNavigationGroup();
$group_category = new VcosNavigationGroupCategory();
$nav = isset($_POST['nav']) ? $_POST['nav'] : 0;
$val = isset($_POST['val']) ? $_POST['val'] : 0;
$parent = isset($_POST['parent']) ? $_POST['parent'] : 0;
$name = isset($_POST['name']) ? $_POST['name'] : '';
$sort = isset($_POST['sort']) ? $_POST['sort'] : '';
$img_name = isset($_POST['img_name']) ? $_POST['img_name'] : '';
$cat_name = isset($_POST['cat_name']) ? $_POST['cat_name'] : '';
$highlight = isset($_POST['highlight']) ? $_POST['highlight'] : 0;
//var_dump($_POST);exit;
if ($val == 0 || $val == '') {
//新增
if ($parent == 0) {
$photo = '';
if ($_FILES[$img_name]['error'] != 4) {
$result = Helper::upload_file($img_name, Yii::app()->params['img_save_url'] . 'navigation_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$photo_url = 'navigation_images/' . Yii::app()->params['month'] . '/' . $photo;
//事务处理
$transaction = $p_db->beginTransaction();
try {
$group->navigation_id = $nav;
$group->navigation_group_name = $name;
$group->sort_order = $sort;
$group->img_url = $photo_url;
$group->save();
//$id = $group->attributes['navigation_group_id'];
$transaction->commit();
Helper::show_message(yii::t('vcos', '添加成功。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1)));
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '添加失败。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1)));
}
} else {
//事务处理
$transaction = $p_db->beginTransaction();
try {
$group_category->navigation_group_id = $parent;
$group_category->navigation_category_name = $name;
$group_category->sort_order = $sort;
$group_category->is_highlight = $highlight;
$group_category->category_type = 1;
$group_category->mapping_id = $cat_name;
$group_category->save();
//$id = $group->attributes['navigation_group_id'];
$transaction->commit();
Helper::show_message(yii::t('vcos', '添加成功。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1)));
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '添加失败。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1)));
}
}
} else {
//修改
if ($parent == 0) {
$photo = '';
if ($_FILES[$img_name]['error'] != 4) {
$result = Helper::upload_file($img_name, Yii::app()->params['img_save_url'] . 'navigation_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$photo_url = 'navigation_images/' . Yii::app()->params['month'] . '/' . $photo;
//事务处理
$transaction = $p_db->beginTransaction();
try {
if ($photo == '') {
$sql = "UPDATE `vcos_navigation_group` SET navigation_group_name='{$name}' WHERE navigation_group_id='{$val}'";
} else {
$sql = "UPDATE `vcos_navigation_group` SET navigation_group_name='{$name}',img_url='{$photo_url}' WHERE navigation_group_id='{$val}'";
}
Yii::app()->p_db->createCommand($sql)->execute();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1)));
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1)));
}
} else {
//事务处理
$transaction = $p_db->beginTransaction();
try {
$sql = "UPDATE `vcos_navigation_group_category` SET navigation_category_name='{$name}',mapping_id='{$cat_name}',is_highlight='{$highlight}' WHERE navigation_group_cid='{$val}'";
Yii::app()->p_db->createCommand($sql)->execute();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1)));
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'), Yii::app()->createUrl("Navigation/nav_column_set", array('nav' => $nav, 'act' => 'category', 'op' => 1)));
}
}
}
}
示例3: actionAd_edit
public function actionAd_edit()
{
$this->setauth();
//检查有无权限
$id = $_GET['id'];
$ad = VcosAd::model()->findByPk($id);
$sql = "SELECT b.id FROM vcos_ad a LEFT JOIN vcos_ad_language b ON a.ad_id = b.ad_id WHERE a.ad_id = {$id} AND b.iso ='" . Yii::app()->params['language'] . "'";
$id2 = Yii::app()->m_db->createCommand($sql)->queryRow();
$ad_language = VcosAdLanguage::model()->findByPk($id2['id']);
if ($_POST) {
/*
$photo='';
if($_FILES['photo']['error']!=4){
$result=Helper::upload_file('photo', Yii::app()->params['img_save_url'].'myad_images/'.Yii::app()->params['month'], 'image', 3);
$photo=$result['filename'];
}*/
$photo = '';
$photo_iso = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'myad_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
if (isset($_POST['language']) && $_POST['language'] != '') {
if ($_FILES['photo_iso']['error'] != 4) {
$result = Helper::upload_file('photo_iso', Yii::app()->params['img_save_url'] . 'myad_images/' . Yii::app()->params['month'], 'image', 3);
$photo_iso = $result['filename'];
}
}
/*
$photo_iso_url = '';
if($photo_iso){//判断有无上传图片
$photo_iso_url = 'myad_images/'.Yii::app()->params['month'].'/'.$photo_iso;
}*/
$photo_url = '';
if ($photo) {
//判断有无上传图片
$photo_url = 'myad_images/' . Yii::app()->params['month'] . '/' . $photo;
}
if ($_POST['type'] == 0) {
//模块
$link_url = "article?article_id=" . $_POST['link_model'];
if (isset($_POST['language']) && $_POST['language'] != '') {
$link_url_iso = "article?article_id=" . $_POST['link_model_iso'];
}
} else {
if ($_POST['type'] == 1) {
$link_url = $_POST['link_url'];
if (isset($_POST['language']) && $_POST['language'] != '') {
$link_url_iso = $_POST['link_url_iso'];
}
}
}
$state = isset($_POST['state']) ? $_POST['state'] : '0';
$db = Yii::app()->m_db;
$transaction = $db->beginTransaction();
try {
if (isset($_POST['language']) && $_POST['language'] != '') {
//编辑系统语言和外语状态下
//编辑主表
$columns = array('ad_state' => $state, 'ad_position' => $_POST['position'], 'link_type' => $_POST['type']);
$db->createCommand()->update('vcos_ad', $columns, 'ad_id = :id', array(':id' => $id));
//编辑系统语言
$l_colums = array('name' => $_POST['title'], 'link_url' => $link_url);
if ($photo) {
//判断有无上传图片
$l_colums['img_url'] = 'myad_images/' . Yii::app()->params['month'] . '/' . $photo;
}
$db->createCommand()->update('vcos_ad_language', $l_colums, 'id=:id', array(':id' => $id2['id']));
//判断外语是新增OR编辑
if ($_POST['judge'] == 'add') {
//新增外语
$columns = array('ad_id' => $id, 'iso' => $_POST['language'], 'name' => $_POST['title_iso'], 'link_url' => $link_url_iso);
if ($photo_iso) {
//判断有无上传图片
$columns['img_url'] = 'myad_images/' . Yii::app()->params['month'] . '/' . $photo_iso;
}
$db->createCommand()->insert('vcos_ad_language', $columns);
} else {
//编辑外语
$columns = array('name' => $_POST['title_iso'], 'link_url' => $link_url_iso);
if ($photo_iso) {
//判断有无上传图片
$columns['img_url'] = 'myad_images/' . Yii::app()->params['month'] . '/' . $photo_iso;
}
$db->createCommand()->update('vcos_ad_language', $columns, 'id=:id', array(':id' => $_POST['judge']));
}
//事务提交
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Ad/ad_list"));
} else {
//只编辑系统语言状态下
$ad->ad_id = $id;
$ad->ad_state = $state;
$ad->ad_position = $_POST['position'];
$ad->link_type = $_POST['type'];
$ad->save();
$ad_language->id = $id2['id'];
$ad_language->name = $_POST['title'];
if ($photo) {
//判断有无上传图片
//.........这里部分代码省略.........
示例4: actionProduct_graphic_edit
public function actionProduct_graphic_edit()
{
$this->setauth();
//检查有无权限
$p_db = Yii::app()->p_db;
$id = $_GET['id'];
$product_graphic = VcosProductGraphic::model()->findByPk($id);
if ($_POST) {
$product = isset($_POST['product']) ? $_POST['product'] : 0;
$desc = isset($_POST['desc']) ? $_POST['desc'] : '';
$sort = isset($_POST['sort']) ? $_POST['sort'] : 0;
$photo = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'product_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$photo_url = 'product_images/' . Yii::app()->params['month'] . '/' . $photo;
//事务处理
$transaction = $p_db->beginTransaction();
try {
$product_graphic->product_id = $product;
if ($desc != '') {
$product_graphic->graphic_desc = $desc;
}
if ($photo) {
$product_graphic->img_url = $photo_url;
}
$product_graphic->sort_order = $sort;
$product_graphic->save();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Product/product_graphic_list"));
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'));
}
}
$sql = "SELECT category_code FROM `vcos_product` WHERE product_id=" . $product_graphic['product_id'];
$category_code = Yii::app()->p_db->createCommand($sql)->queryRow();
$category_code = $category_code['category_code'];
$sql = "SELECT parent_cid FROM `vcos_category` WHERE category_code =" . $category_code;
$layer_cat_2 = $p_db->createCommand($sql)->queryRow();
$sql = "SELECT parent_cid FROM `vcos_category` WHERE category_code =" . $layer_cat_2['parent_cid'];
$layer_cat_1 = $p_db->createCommand($sql)->queryRow();
$sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=0";
$layer_1 = $p_db->createCommand($sql)->queryAll();
$sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_cat_1['parent_cid'];
$layer_2 = $p_db->createCommand($sql)->queryAll();
$sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_cat_2['parent_cid'];
$layer_3 = $p_db->createCommand($sql)->queryAll();
$sql = "SELECT product_id,product_name FROM `vcos_product` WHERE category_code=" . $category_code;
$product = $p_db->createCommand($sql)->queryAll();
$layer_cat = $layer_cat_1['parent_cid'];
$layer_cat2 = $layer_cat_2['parent_cid'];
$this->render('product_graphic_edit', array('product_graphic' => $product_graphic, 'product' => $product, 'layer_cat' => $layer_cat, 'layer_cat2' => $layer_cat2, 'layer_1' => $layer_1, 'layer_2' => $layer_2, 'layer_3' => $layer_3, 'category_code' => $category_code));
}
示例5: actionGoods_category_edit
public function actionGoods_category_edit()
{
$this->setauth();
//检查有无权限
$id = $_GET['id'];
$category = VcosDutyfreeGoodsCategory::model()->findByPk($id);
$sql = "SELECT b.id FROM vcos_dutyfree_goods_category a LEFT JOIN vcos_dutyfree_goods_category_language b ON a.gc_id = b.gc_id WHERE a.gc_id = {$id} AND b.iso ='" . Yii::app()->params['language'] . "'";
$id2 = Yii::app()->m_db->createCommand($sql)->queryRow();
$category_language = VcosDutyfreeGoodsCategoryLanguage::model()->findByPk($id2['id']);
if ($_POST) {
$photo = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'dutyfreegoods_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$state = isset($_POST['state']) ? $_POST['state'] : '0';
if ($state == '0') {
$result = VcosDutyfreeGoods::model()->count('goods_category=:id', array(':id' => $id));
if ($result > 0) {
die(Helper::show_message(yii::t('vcos', '此分类正在使用,不能禁用。')));
}
}
//事务处理
$db = Yii::app()->m_db;
$transaction = $db->beginTransaction();
try {
if (isset($_POST['language']) && $_POST['language'] != '') {
//编辑系统语言和外语状态下
//编辑主表
$columns = array('state' => $state, 'bg_color' => $_POST['bgcolor']);
if ($photo) {
//判断有无上传图片
$columns['gc_img_url'] = 'dutyfreegoods_images/' . Yii::app()->params['month'] . '/' . $photo;
}
$db->createCommand()->update('vcos_dutyfree_goods_category', $columns, 'gc_id = :id', array(':id' => $id));
//编辑系统语言
$db->createCommand()->update('vcos_dutyfree_goods_category_language', array('gc_name' => $_POST['title']), 'id=:id', array(':id' => $id2['id']));
//判断外语是新增OR编辑
if ($_POST['judge'] == 'add') {
//新增外语
$db->createCommand()->insert('vcos_dutyfree_goods_category_language', array('gc_id' => $id, 'iso' => $_POST['language'], 'gc_name' => $_POST['title_iso']));
} else {
//编辑外语
$db->createCommand()->update('vcos_dutyfree_goods_category_language', array('gc_name' => $_POST['title_iso']), 'id=:id', array(':id' => $_POST['judge']));
}
//事务提交
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Dutyfreegoods/Goods_category"));
} else {
//只编辑系统语言
$category->gc_id = $id;
$category->bg_color = $_POST['bgcolor'];
$category->state = $state;
if ($photo) {
$category->gc_img_url = 'dutyfreegoods_images/' . Yii::app()->params['month'] . '/' . $photo;
}
$category->save();
$category_language->id = $id2['id'];
$category_language->gc_name = $_POST['title'];
$category_language->save();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Dutyfreegoods/Goods_category"));
}
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'));
}
}
$this->render('goods_category_edit', array('category' => $category, 'category_language' => $category_language));
}
示例6: actionRoom_detail_edit
public function actionRoom_detail_edit()
{
$this->setauth();
//检查有无权限
$id = $_GET['id'];
$detail = VcosRoomDetail::model()->findByPk($id);
$sql = "SELECT b.id FROM vcos_room_detail a LEFT JOIN vcos_room_detail_language b ON a.detail_id = b.detail_id WHERE a.detail_id = {$id} AND b.iso ='" . Yii::app()->params['language'] . "'";
$id2 = Yii::app()->m_db->createCommand($sql)->queryRow();
$detail_language = VcosRoomDetailLanguage::model()->findByPk($id2['id']);
if ($_POST) {
$photo = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'room_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$state = isset($_POST['state']) ? $_POST['state'] : '0';
//匹配替换编辑器中图片路径
$msg = $_POST['describe'];
$img_ueditor = Yii::app()->params['img_ueditor_php'];
$describe = preg_replace($img_ueditor, '', $msg);
if ($_POST['describe_iso'] != '') {
$msg_iso = $_POST['describe_iso'];
$describe_iso = preg_replace($img_ueditor, '', $msg_iso);
}
//事务处理
$db = Yii::app()->m_db;
$transaction = $db->beginTransaction();
try {
if (isset($_POST['language']) && $_POST['language'] != '') {
//编辑系统语言和外语状态下
//编辑主表
$columns = array('room_id' => $_POST['room'], 'detail_state' => $state);
if ($photo) {
//判断有无上传图片
$columns['room_img_url'] = 'room_images/' . Yii::app()->params['month'] . '/' . $photo;
}
$db->createCommand()->update('vcos_room_detail', $columns, 'detail_id = :id', array(':id' => $id));
//编辑系统语言
$db->createCommand()->update('vcos_room_detail_language', array('room_describe' => $describe), 'id=:id', array(':id' => $id2['id']));
//判断外语是新增OR编辑
if ($_POST['judge'] == 'add') {
//新增外语
$db->createCommand()->insert('vcos_room_detail_language', array('detail_id' => $id, 'iso' => $_POST['language'], 'room_describe' => $describe_iso));
} else {
//编辑外语
$db->createCommand()->update('vcos_room_detail_language', array('room_describe' => $describe_iso), 'id=:id', array(':id' => $_POST['judge']));
}
//事务提交
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Room/room_detail"));
} else {
//只编辑系统语言状态下
$detail->detail_id = $id;
$detail->room_id = $_POST['room'];
$detail->detail_state = $state;
if ($photo != '') {
$detail->room_img_url = 'room_images/' . Yii::app()->params['month'] . '/' . $photo;
}
$detail->save();
$detail_language->id = $id2['id'];
$detail_language->room_describe = $describe;
$detail_language->save();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Room/room_detail"));
}
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'), '#');
}
}
$sql = "SELECT * FROM vcos_room a LEFT JOIN vcos_room_language b ON a.room_id = b.room_id WHERE a.room_state = '1' AND b.iso = '" . Yii::app()->language . "'";
$room = Yii::app()->m_db->createCommand($sql)->queryAll();
$this->render('room_detail_edit', array('room' => $room, 'detail' => $detail, 'detail_language' => $detail_language));
}
示例7: actionService_img_edit
public function actionService_img_edit()
{
$this->setauth();
//检查有无权限
$id = $_GET['id'];
$lifeservice_img = VcosLifeserviceImg::model()->findByPk($id);
$sql = "SELECT ls_category FROM `vcos_lifeservice` WHERE ls_id = " . $lifeservice_img['lifeservice_id'];
$lifeservice_category = Yii::app()->m_db->createCommand($sql)->queryRow();
if ($_POST) {
$photo = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'lifeservice_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$state = isset($_POST['state']) ? $_POST['state'] : '0';
$iso = isset($_POST['language']) ? $_POST['language'] : 'zh_cn';
//事务处理
$db = Yii::app()->m_db;
$transaction = $db->beginTransaction();
try {
$lifeservice_img->id = $id;
$lifeservice_img->lifeservice_id = $_POST['life_category'];
$lifeservice_img->state = $state;
$lifeservice_img->iso = $iso;
if ($photo) {
$lifeservice_img->img_url = 'lifeservice_images/' . Yii::app()->params['month'] . '/' . $photo;
}
$lifeservice_img->save();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Lifeservice/Service_img_list"));
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'), '#');
}
}
$life_sql = "SELECT a.lc_id,b.lc_name FROM vcos_lifeservice_category a LEFT JOIN vcos_lifeservice_category_language b ON a.lc_id = b.lc_id WHERE b.iso = '" . Yii::app()->language . "' AND a.lc_state = '1'";
$lifeservice_sel = Yii::app()->m_db->createCommand($life_sql)->queryAll();
$sql = "SELECT a.ls_id,b.ls_title FROM vcos_lifeservice a LEFT JOIN vcos_lifeservice_language b ON a.ls_id = b.ls_id WHERE (a.ls_state = '1' OR a.ls_id={$lifeservice_img['lifeservice_id']}) AND b.iso = '" . Yii::app()->language . "' AND a.ls_category = " . $lifeservice_category['ls_category'];
$life_title_sel = Yii::app()->m_db->createCommand($sql)->queryAll();
$this->render('service_img_edit', array('life_title_sel' => $life_title_sel, 'lifeservice_sel' => $lifeservice_sel, 'lifeservice_img' => $lifeservice_img, 'lifeservice_category' => $lifeservice_category['ls_category']));
}
示例8: actionArticle_edit
public function actionArticle_edit()
{
$this->setauth();
// 检查有无权限
$id = $_GET['id'];
$article = VcosArticle::model()->findByPk($id);
$sql = "SELECT b.id FROM vcos_article a LEFT JOIN vcos_article_language b ON a.article_id = b.article_id WHERE a.article_id = {$id} AND b.iso ='" . Yii::app()->params['language'] . "'";
$id2 = Yii::app()->m_db->createCommand($sql)->queryRow();
$article_language = VcosArticleLanguage::model()->findByPk($id2['id']);
if ($_POST) {
$photo = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'article_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$state = isset($_POST['state']) ? $_POST['state'] : '0';
$times = date("Y/m/d H:i:s", time());
$time = explode(" - ", $_POST['time']);
$s_time = $time[0] . ' ' . $_POST['stime'];
$e_time = $time[1] . ' ' . $_POST['etime'];
$stime = date('Y/m/d H:i:s', strtotime($s_time));
$etime = date('Y/m/d H:i:s', strtotime($e_time));
// 匹配替换编辑器中图片路径
$msg = $_POST['contents'];
$img_ueditor = Yii::app()->params['img_ueditor_php'];
$describe = preg_replace($img_ueditor, '', $msg);
if ($_POST['contents_iso'] != '') {
$msg_iso = $_POST['contents_iso'];
$describe_iso = preg_replace($img_ueditor, '', $msg_iso);
}
// 事务处理
$db = Yii::app()->m_db;
$transaction = $db->beginTransaction();
try {
if (isset($_POST['language']) && $_POST['language'] != '') {
// 编辑系统语言和外语状态下
// 编辑主表
$columns = array('article_time' => $times, 'article_start_time' => $stime, 'article_end_time' => $etime, 'article_state' => $state);
if ($photo) {
// 判断有无上传图片
$columns['article_img_url'] = 'article_images/' . Yii::app()->params['month'] . '/' . $photo;
}
$db->createCommand()->update('vcos_article', $columns, 'article_id = :id', array(':id' => $id));
// 编辑系统语言
$db->createCommand()->update('vcos_article_language', array('article_title' => $_POST['title'], 'article_abstract' => $_POST['abstract'], 'article_content' => $describe), 'id=:id', array(':id' => $id2['id']));
// 判断外语是新增OR编辑
if ($_POST['judge'] == 'add') {
// 新增外语
$db->createCommand()->insert('vcos_article_language', array('article_id' => $id, 'iso' => $_POST['language'], 'article_title' => $_POST['title_iso'], 'article_abstract' => $_POST['abstract_iso'], 'article_content' => $describe_iso));
} else {
// 编辑外语
$db->createCommand()->update('vcos_article_language', array('article_title' => $_POST['title_iso'], 'article_abstract' => $_POST['abstract_iso'], 'article_content' => $describe_iso), 'id=:id', array(':id' => $_POST['judge']));
}
// 事务提交
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Article/Article_list"));
} else {
// 只编辑系统语言
$article->article_id = $id;
$article->article_time = $times;
$article->article_start_time = $stime;
$article->article_end_time = $etime;
$article->article_state = $state;
if ($photo) {
$article->article_img_url = 'article_images/' . Yii::app()->params['month'] . '/' . $photo;
}
$article->save();
$article_language->id = $id2['id'];
$article_language->article_content = $describe;
$article_language->article_title = $_POST['title'];
$article_language->article_abstract = $_POST['abstract'];
$article_language->save();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Article/Article_list"));
}
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'));
}
}
$this->render('article_edit', array('article' => $article, 'article_language' => $article_language));
}
示例9: actionCommentandhelp_category_edit
public function actionCommentandhelp_category_edit()
{
if ($this->auth[0] == '0') {
$access = TRUE;
} else {
$error = Yii::app()->createUrl('error/index');
$this->redirect($error);
}
$id = $_GET['id'];
$category = VcosCommentAndHelpCategory::model()->findByPk($id);
if ($_POST) {
$photo = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'system_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$state = isset($_POST['state']) ? $_POST['state'] : '0';
if ($_POST['name'] != '' && $_POST['url'] != '' && $_POST['bgcolor'] != '') {
$category->id = $id;
$category->cnh_category_name = $_POST['name'];
$category->cnh_herf_url = $_POST['url'];
$category->bg_color = $_POST['bgcolor'];
$category->state = $state;
if ($photo) {
$old = Yii::app()->params['img_save_url'] . $category['cnh_img_url'];
if (file_exists($old) && $category['cnh_img_url']) {
unlink($old);
}
$category->cnh_img_url = 'system_images/' . Yii::app()->params['month'] . '/' . $photo;
}
if ($category->save() > 0) {
Helper::show_message(yii::t('vcos', '修改成功'), Yii::app()->createUrl("Systemsetting/Commentandhelp_category"));
} else {
Helper::show_message(yii::t('vcos', '修改失败'));
}
} else {
Helper::show_message(yii::t('vcos', '修改失败'));
}
}
$this->render('commentandhelp_category_edit', array('category' => $category));
}
示例10: actionMain_nav_edit
public function actionMain_nav_edit()
{
$this->setauth();
//检查有无权限
$id = $_GET['id'];
$main_nav = VcosMainNav::model()->findByPk($id);
$sql = "SELECT b.id FROM vcos_main_nav a LEFT JOIN vcos_main_nav_language b ON a.nav_id = b.nav_id WHERE a.nav_id = {$id} AND b.iso ='" . Yii::app()->language . "'";
$id2 = Yii::app()->m_db->createCommand($sql)->queryRow();
$main_nav_language = VcosMainNavLanguage::model()->findByPk($id2['id']);
if ($_POST) {
$photo = '';
$photo_iso = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'main_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
if (isset($_POST['language']) && $_POST['language'] != '') {
if ($_FILES['photo_iso']['error'] != 4) {
$result = Helper::upload_file('photo_iso', Yii::app()->params['img_save_url'] . 'main_images/' . Yii::app()->params['month'], 'image', 3);
$photo_iso = $result['filename'];
}
}
$photo_url = '';
if ($photo) {
//判断有无上传图片
$photo_url = 'main_images/' . Yii::app()->params['month'] . '/' . $photo;
}
//$state = isset($_POST['state'])?$_POST['state']:'0';
//事务处理
$db = Yii::app()->m_db;
$transaction = $db->beginTransaction();
try {
if (isset($_POST['language']) && $_POST['language'] != '') {
//编辑系统语言和外语状态下
//编辑主表
$columns = array('state' => $_POST['state'], 'sequence' => $_POST['sequence'], 'category_id' => $_POST['category']);
$db->createCommand()->update('vcos_main_nav', $columns, 'nav_id = :id', array(':id' => $id));
//编辑系统语言
$columns = array('name' => $_POST['name'], 'bg_color' => $_POST['bgcolor']);
if ($photo) {
//判断有无上传图片
$columns['img_url'] = 'main_images/' . Yii::app()->params['month'] . '/' . $photo;
}
$db->createCommand()->update('vcos_main_nav_language', $columns, 'id=:id', array(':id' => $id2['id']));
//判断外语是新增OR编辑
if ($_POST['judge'] == 'add') {
//新增外语
$columns = array('nav_id' => $id, 'iso' => $_POST['language'], 'name' => $_POST['name_iso'], 'bg_color' => $_POST['bgcolor']);
if ($photo_iso) {
//判断有无上传图片
$columns['img_url'] = 'main_images/' . Yii::app()->params['month'] . '/' . $photo_iso;
}
$db->createCommand()->insert('vcos_main_nav_language', $columns);
} else {
//编辑外语
$columns = array('name' => $_POST['name_iso'], 'bg_color' => $_POST['bgcolor']);
if ($photo_iso) {
//判断有无上传图片
$columns['img_url'] = 'main_images/' . Yii::app()->params['month'] . '/' . $photo_iso;
}
$db->createCommand()->update('vcos_main_nav_language', $columns, 'id=:id', array(':id' => $_POST['judge']));
}
//事务提交
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Main/Main_nav_list"));
} else {
//只编辑系统语言状态下
$main_nav->nav_id = $id;
$main_nav->state = $_POST['state'];
$main_nav->sequence = $_POST['sequence'];
$main_nav->category_id = $_POST['category'];
$main_nav->save();
$main_nav_language->id = $id2['id'];
$main_nav_language->name = $_POST['name'];
$main_nav_language->bg_color = $_POST['bgcolor'];
//$main_nav_language->img_url = $photo_url;
if ($photo) {
//判断有无上传图片
$main_nav_language->img_url = 'main_images/' . Yii::app()->params['month'] . '/' . $photo;
}
$main_nav_language->save();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Main/Main_nav_list"));
}
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'), '#');
}
}
$sql = "SELECT a.main_id,b.name FROM `vcos_main_category` a LEFT JOIN `vcos_main_category_language` b ON a.main_id = b.main_id WHERE a.state = '1' AND b.iso = '" . Yii::app()->language . "'";
$category_sel = Yii::app()->m_db->createCommand($sql)->queryAll();
$this->render('main_nav_edit', array('category_sel' => $category_sel, 'main_nav' => $main_nav, 'main_nav_language' => $main_nav_language));
}
示例11: actionBrand_edit
public function actionBrand_edit()
{
$this->setauth();
//检查有无权限
$p_db = Yii::app()->p_db;
$id = $_GET['id'];
$brand = VcosBrand::model()->findByPk($id);
if ($_POST) {
$name = isset($_POST['name']) ? $_POST['name'] : '';
$names = isset($_POST['names']) ? $_POST['names'] : '';
$country = isset($_POST['country']) ? $_POST['country'] : 0;
$desc = isset($_POST['desc']) ? $_POST['desc'] : '';
$photo = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'activity_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$photo_url = 'activity_images/' . Yii::app()->params['month'] . '/' . $photo;
$state = isset($_POST['state']) ? $_POST['state'] : '0';
//事务处理
$transaction = $p_db->beginTransaction();
try {
$brand->brand_cn_name = $name;
$brand->brand_en_name = $names;
$brand->country_id = $country;
$brand->brand_desc = $desc;
$brand->brand_status = $state;
if ($photo) {
$brand->brand_logo = $photo_url;
}
$brand->save();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Brand/brand_list"));
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'));
}
}
$sql = "SELECT country_id,country_cn_name FROM `vcos_country` WHERE status =1";
$country = Yii::app()->p_db->createCommand($sql)->queryAll();
$this->render('brand_edit', array('brand' => $brand, 'country' => $country));
}
示例12: actionShop_edit
public function actionShop_edit()
{
$this->setauth();
//检查有无权限
$p_db = Yii::app()->p_db;
$id = $_GET['id'];
$shop = VcosShop::model()->findByPk($id);
if ($_POST) {
$code = isset($_POST['code']) ? $_POST['code'] : '';
$name = isset($_POST['name']) ? $_POST['name'] : '';
$desc = isset($_POST['desc']) ? $_POST['desc'] : '';
$people = isset($_POST['people']) ? $_POST['people'] : '';
$company = isset($_POST['company']) ? $_POST['company'] : '';
$address = isset($_POST['address']) ? $_POST['address'] : '';
$price = isset($_POST['price']) ? $_POST['price'] * 100 : '';
$products = isset($_POST['products']) ? $_POST['products'] : '';
$photo = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'shop_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$photo_url = 'shop_images/' . Yii::app()->params['month'] . '/' . $photo;
$photo1 = '';
if ($_FILES['photo1']['error'] != 4) {
$result = Helper::upload_file('photo1', Yii::app()->params['img_save_url'] . 'shop_images/' . Yii::app()->params['month'], 'image', 3);
$photo1 = $result['filename'];
}
$photo_url1 = 'shop_images/' . Yii::app()->params['month'] . '/' . $photo1;
$photo2 = '';
if ($_FILES['photo2']['error'] != 4) {
$result = Helper::upload_file('photo2', Yii::app()->params['img_save_url'] . 'shop_images/' . Yii::app()->params['month'], 'image', 3);
$photo2 = $result['filename'];
}
$photo_url2 = 'shop_images/' . Yii::app()->params['month'] . '/' . $photo2;
$state = isset($_POST['state']) ? $_POST['state'] : '0';
$create_times = date("Y/m/d H:i:s", time());
$cruise_id = Yii::app()->params['cruise_id'];
//事务处理
$transaction = $p_db->beginTransaction();
try {
$shop->shop_code = $code;
$shop->shop_title = $name;
if ($photo) {
$shop->shop_logo = $photo_url;
}
if ($photo1) {
$shop->shop_img_url = $photo_url1;
}
if ($photo2) {
$shop->business_license = $photo_url2;
}
$shop->shop_desc = $desc;
$shop->legal_representative = $people;
$shop->company_name = $company;
$shop->shop_address = $address;
$shop->cash_deposit = $price;
$shop->main_products = $products;
$shop->created = $create_times;
$shop->shop_status = $state;
$shop->cruise_id = $cruise_id;
$shop->save();
//修改活动商品(栏目页面配置是否有效问题)
$sql = "SELECT is_delete FROM `vcos_shop` WHERE shop_id='{$id}'";
$this_data = Yii::app()->p_db->createCommand($sql)->queryRow();
if ($state == 0) {
$flag = 1;
} else {
if ($state == 1) {
if ($this_data['is_delete'] == 1) {
$flag = 1;
} else {
$flag = 0;
}
}
}
if ($flag == 1) {
$sql = "UPDATE `vcos_activity_product` SET is_overdue=1 WHERE product_id='{$id}' AND product_type=3";
} else {
if ($flag == 0) {
$sql = "UPDATE `vcos_activity_product` SET is_overdue=0 WHERE product_id='{$id}' AND product_type=3";
}
}
$p_db->createCommand($sql)->execute();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Shop/shop_list"));
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'));
}
}
$sql = "SELECT a.*,b.name,c.name parent_name FROM `vcos_shop_operation_category` a LEFT JOIN `vcos_category` b ON a.category_code=b.category_code LEFT JOIN `vcos_category` c ON a.parent_catogory_code=c.category_code WHERE a.status=1 AND a.shop_id=" . $id;
$shop_operation = Yii::app()->p_db->createCommand($sql)->queryAll();
$shop_operation = self::shopsortOut($shop_operation);
//var_dump($shop_operation);exit;
$sql = "SELECT * FROM `vcos_shop_category` a LEFT JOIN\r\n\t\t(SELECT parent_cid,count(parent_cid) count FROM `vcos_shop_category` b WHERE shop_id=" . $id . " GROUP BY parent_cid) b ON a.parent_cid=b.parent_cid\r\n\t\tWHERE a.shop_id=" . $id . " ORDER BY sort_order";
$shop_cat = $p_db->createCommand($sql)->queryAll();
$shop_cat = self::sortOut($shop_cat);
$this->render('shop_edit', array('shop_cat' => $shop_cat, 'shop' => $shop, 'auth' => $this->auth, 'shop_operation' => $shop_operation));
}
示例13: actionRestaurant_img_edit
public function actionRestaurant_img_edit()
{
$this->setauth();
//检查有无权限
$id = $_GET['id'];
$restaurant_img = VcosRestaurantImg::model()->findByPk($id);
if ($_POST) {
$photo = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'restaurant_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$state = isset($_POST['state']) ? $_POST['state'] : '0';
$iso = isset($_POST['language']) ? $_POST['language'] : 'zh_cn';
/*
if($state == '0'){
$result = VcosRestaurantImg::model()->count('id=:id',array(':id'=>$id));
if($result>0){
die(Helper::show_message(yii::t('vcos', '此分类正在使用,不能禁用')));
}
}*/
//事务处理
$db = Yii::app()->m_db;
$transaction = $db->beginTransaction();
try {
$restaurant_img->id = $id;
$restaurant_img->restaurant_id = $_POST['restaurant'];
$restaurant_img->state = $state;
$restaurant_img->iso = $iso;
if ($photo) {
$restaurant_img->img_url = 'restaurant_images/' . Yii::app()->params['month'] . '/' . $photo;
}
$restaurant_img->save();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Restaurant/Restaurant_img_list"));
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'), '#');
}
}
$res_sql = "SELECT a.restaurant_id,b.restaurant_name FROM vcos_restaurant a LEFT JOIN vcos_restaurant_language b ON a.restaurant_id = b.restaurant_id WHERE b.iso = '" . Yii::app()->language . "' AND a.restaurant_state = '1'";
$restaurant_sel = Yii::app()->m_db->createCommand($res_sql)->queryAll();
$this->render('restaurant_img_edit', array('restaurant_sel' => $restaurant_sel, 'restaurant_img' => $restaurant_img));
}
示例14: actionNotice_to_visitors_edit
public function actionNotice_to_visitors_edit()
{
$this->setauth();
//检查有无权限
$id = $_GET['id'];
$notice_to_visitors = VcosNoticeToVisitors::model()->findByPk($id);
$sql = "SELECT b.id FROM vcos_notice_to_visitors a LEFT JOIN vcos_notice_to_visitors_language b ON a.id = b.n_id WHERE a.id = {$id} AND b.iso ='" . Yii::app()->language . "'";
$id2 = Yii::app()->m_db->createCommand($sql)->queryRow();
$notice_to_visitors_language = VcosNoticeToVisitorsLanguage::model()->findByPk($id2['id']);
if ($_POST) {
$photo = '';
$photo_iso = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'safe_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
if (isset($_POST['language']) && $_POST['language'] != '') {
if ($_FILES['photo_iso']['error'] != 4) {
$result = Helper::upload_file('photo_iso', Yii::app()->params['img_save_url'] . 'safe_images/' . Yii::app()->params['month'], 'image', 3);
$photo_iso = $result['filename'];
}
}
$state = isset($_POST['state']) ? $_POST['state'] : '0';
//匹配替换编辑器中图片路径
$msg = $_POST['describe'];
$img_ueditor = Yii::app()->params['img_ueditor_php'];
$describe = preg_replace($img_ueditor, '', $msg);
if ($_POST['describe_iso'] != '') {
$msg_iso = $_POST['describe_iso'];
$describe_iso = preg_replace($img_ueditor, '', $msg_iso);
}
//事务处理
$db = Yii::app()->m_db;
$transaction = $db->beginTransaction();
try {
if (isset($_POST['language']) && $_POST['language'] != '') {
//编辑系统语言和外语状态下
//编辑主表
$columns = array('state' => $state, 'sort_order' => $_POST['sort'], 'category_id' => $_POST['category']);
$db->createCommand()->update('vcos_notice_to_visitors', $columns, 'id = :id', array(':id' => $id));
if ($photo_iso) {
//判断有无上传图片
$photo_iso_url = 'safe_images/' . Yii::app()->params['month'] . '/' . $photo_iso;
}
$columns_iso = array('content' => $describe);
if ($photo != '') {
//判断有无上传图片
$columns_iso['img_url'] = 'safe_images/' . Yii::app()->params['month'] . '/' . $photo;
}
//编辑系统语言
$db->createCommand()->update('vcos_notice_to_visitors_language', $columns_iso, 'id=:id', array(':id' => $id2['id']));
//判断外语是新增OR编辑
if ($_POST['judge'] == 'add') {
//新增外语
$db->createCommand()->insert('vcos_notice_to_visitors_language', array('n_id' => $id, 'iso' => $_POST['language'], 'img_url' => $photo_iso_url, 'content' => $describe_iso));
} else {
//编辑外语
$columns_iso_language = array('content' => $describe_iso);
if ($photo_iso != '') {
//判断有无上传图片
$columns_iso_language['img_url'] = 'safe_images/' . Yii::app()->params['month'] . '/' . $photo_iso;
}
$db->createCommand()->update('vcos_notice_to_visitors_language', $columns_iso_language, 'id=:id', array(':id' => $_POST['judge']));
}
//事务提交
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Safe/notice_to_visitors"));
} else {
//只编辑系统语言状态下
$notice_to_visitors->state = $state;
$notice_to_visitors->sort_order = $_POST['sort'];
$notice_to_visitors->category_id = $_POST['category'];
$notice_to_visitors->save();
$notice_to_visitors_language->id = $id2['id'];
if ($photo != '') {
//判断有无上传图片
$notice_to_visitors_language->img_url = 'safe_images/' . Yii::app()->params['month'] . '/' . $photo;
}
//$cruise_deck_point_language->img_url = 'cruiseinfo_images/'.Yii::app()->params['month'].'/'.$photo_iso;
$notice_to_visitors_language->content = $describe;
$notice_to_visitors_language->save();
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Safe/notice_to_visitors"));
}
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'), '#');
}
}
$sql = "SELECT a.id,b.category_name FROM `vcos_notice_to_visitors_category` a LEFT JOIN `vcos_notice_to_visitors_category_language` b ON a.id=b.category_id WHERE a.state = 1 AND b.iso = '" . Yii::app()->language . "'";
$category_sel = Yii::app()->m_db->createCommand($sql)->queryAll();
$this->render('notice_to_visitors_edit', array('category_sel' => $category_sel, 'notice_to_visitors' => $notice_to_visitors, 'notice_to_visitors_language' => $notice_to_visitors_language));
}
示例15: actionCruise_model_edit
public function actionCruise_model_edit()
{
$this->setauth();
//检查有无权限
//获取当前配置的默认邮轮
$cruise_id = Yii::app()->params['cruise_id'];
$sql = "SELECT * FROM `vcos_cruise_model` WHERE cruise_id='{$cruise_id}' LIMIT 1";
$model = Yii::app()->m_db->createCommand($sql)->queryRow();
//判断是否提交需判断
if ($model) {
$act = 1;
} else {
$act = 0;
}
if ($_POST) {
$photo = '';
if ($_FILES['photo']['error'] != 4) {
$result = Helper::upload_file('photo', Yii::app()->params['img_save_url'] . 'cruiseinfo_images/' . Yii::app()->params['month'], 'image', 3);
$photo = $result['filename'];
}
$photo1 = '';
if ($_FILES['photo1']['error'] != 4) {
$result = Helper::upload_file('photo1', Yii::app()->params['img_save_url'] . 'cruiseinfo_images/' . Yii::app()->params['month'], 'image', 3);
$photo1 = $result['filename'];
}
$photo_url = 'cruiseinfo_images/' . Yii::app()->params['month'] . '/' . $photo;
$photo1_url = 'cruiseinfo_images/' . Yii::app()->params['month'] . '/' . $photo1;
//事务处理
$db = Yii::app()->m_db;
$transaction = $db->beginTransaction();
try {
$sql = '';
$sql_u = '';
if ($photo != '' && $photo1 != '') {
$sql = "INSERT INTO `vcos_cruise_model` (cruise_id,img_back,img_back_over) values ('{$cruise_id}','{$photo_url}','{$photo1_url}')";
$sql_u = "UPDATE `vcos_cruise_model` set img_back='{$photo_url}',img_back_over='{$photo1_url}' WHERE cruise_id='{$cruise_id}'";
} else {
if ($photo != '' && $photo1 == '') {
$sql = "INSERT INTO `vcos_cruise_model` (cruise_id,img_back) values ('{$cruise_id}','{$photo_url}')";
$sql_u = "UPDATE `vcos_cruise_model` set img_back='{$photo_url}' WHERE cruise_id='{$cruise_id}'";
} else {
if ($photo == '' && $photo1 != '') {
$sql = "INSERT INTO `vcos_cruise_model` (cruise_id,img_back_over) values ('{$cruise_id}','{$photo1_url}')";
$sql_u = "UPDATE `vcos_cruise_model` set img_back_over='{$photo1_url}' WHERE cruise_id='{$cruise_id}'";
}
}
}
if ($sql != '' || $sql_u != '') {
if ($act == 1) {
Yii::app()->m_db->createCommand($sql_u)->execute();
} else {
Yii::app()->m_db->createCommand($sql)->execute();
}
}
$transaction->commit();
Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Cruiseinfo/cruise_model_edit"));
} catch (Exception $e) {
$transaction->rollBack();
Helper::show_message(yii::t('vcos', '修改失败。'), '#');
}
}
$this->render('cruise_model_edit', array('model' => $model, 'act' => $act));
}