Ejemplo n.º 1
0
 /**
  * draguo
  * return area_id
  * $content_arr is array
  */
 public function update($area_id, $name, $titlepic, $some_pics, $content_arr, $raiders_content, $position, $tier)
 {
     $contentAttachmentDao = new ContentAttachmentDao();
     $some_pic_arr = explode(';', $some_pics);
     if (count($some_pic_arr) < 5) {
         echo "更新失败,介绍内容图片不足";
         exit;
     }
     // 更新基础信息
     $this->UpdataArea($area_id, $name, $parentid, $tier, $position);
     $titlepic_id = $this->addPhoto($titlepic);
     /**
      * 对area_content表重新进行绑定,但是之前的数据并没有被删除
      * 下次进行更正
      */
     $this->delAreaContact($area_id);
     foreach ($content_arr as $value) {
         $content_id = $this->addContent($area_id, $value);
         $this->addAreaContact($area_id, $content_id);
     }
     // title图片和介绍内容最后一个绑定
     $contentAttachmentDao->delByContentId($content_id);
     $contentAttachmentDao->add($content_id, $titlepic_id);
     $content_id = $this->addContent($area_id, $raiders_content, $type = 1);
     $this->addAreaContact($area_id, $content_id);
     // 其余的四张和攻略进行绑定
     foreach ($some_pic_arr as $value) {
         if (!empty($value)) {
             $pic_id = $this->addPhoto($value);
             $contentAttachmentDao->add($content_id, $pic_id);
         }
     }
     return true;
 }
Ejemplo n.º 2
0
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/models/CasaTagDao.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/models/AttachmentDao.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/models/AreaDao.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/models/ContentDao.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/models/ContentAttachmentDao.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/services/CasaService.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/services/ContentService.php';
$casa_JSON_str = remove_slash($_REQUEST['casa_JSON_str']);
$casa = json_decode($casa_JSON_str);
$casaDao = new CasaDao();
$areaDao = new AreaDao();
$attachmentDao = new AttachmentDao();
$tagDao = new TagDao();
$casaTagDao = new CasaTagDao();
$contentDao = new ContentDao();
$contentAttachmentDao = new ContentAttachmentDao();
$casaService = new CasaService();
$contentService = new ContentService();
mysql_query('START TRANSACTION') or die(mysql_error());
$mode = 'edit';
if (empty($casa->id)) {
    $mode = 'add';
}
/** 1.添加基础民宿 */
if (!empty($casa->name) && !empty($casa->code) && !empty($casa->area)) {
    $casa_id = $casaDao->addOrUpdateSimple($casa->name, $casa->code, $casa->link, $casa->area, $casa->id);
    if (!$casa_id) {
        mysql_query('ROLLBACK');
        header('Location:../../website/backstage/error.php?info=添加或更新民宿对象信息失败!' . mysql_error() . '&type=casa');
        exit;
    }