include_once 'WechatArticle.php'; include_once 'WechatArticleDao.php'; $waDao = new WechatArticleDao(); $aDao = new AttachmentDao(); $a_id = $_POST['attachment_id']; $wa_id = $_POST['id']; $type = $_POST['type']; $series = $_POST['series']; if (empty($series)) { $series = 0; } $filepath = $_GET['filepath']; $wa = new WechatArticle($wa_id, $a_id, $_POST['title'], $_POST['brief'], $_POST['address'], $type, $series, $_POST['deleted']); $update_attachemnt = false; if ($a_id) { $attachment_row = $aDao->getById($a_id); if ($attachment_row['filepath'] != $filepath) { // 更新了图片 $update_attachemnt = true; } } else { // 无图片 $update_attachemnt = true; } if ($update_attachemnt) { $a_id = $aDao->addSimple($filepath); if (!$a_id) { echo '数据库添加图片失败!' . '</br>' . mysql_error(); exit; } else { $wa->attachment_id = $a_id;
<div class="nav-right"> <a href=""></a> <a href="">登录</a> <a href="">注册</a> </div> </nav> </header> <section class='tanlu'> <div class='tanlutop'> <h2>探庐·临安</h2> <p>临安介绍 xxxxxxxxxxxxxxxxxxxxxxxxx</p> </div> <?php while ($row = mysql_fetch_array($article_rows)) { $wa = new WechatArticle($row); $a_row = $aDao->getById($wa->attachment_id); if (empty($series) || $series == $wa->series) { ?> <div id="list" class="article_list"> <a href="<?php echo $wa->address; ?> "> <div class="article"> <div class="left"> <img src="http://casarover.oss-cn-hangzhou.aliyuncs.com/casa/<?php echo $a_row['filepath']; ?> "/> </div> <div class="right">
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; } } else { header('Location:../../website/backstage/error.php?info=添加失败,民宿信息不全!&type=casa'); exit; } /** 2.添加民宿默认图 */ if (!empty($casa->main_photo)) { $casa_row = $casaDao->getById($casa_id); if (!empty($casa_row['attachment_id'])) { $attachment_row = $attachmentDao->getById($casa_row['attachment_id']); // 更新了图片 if (!($attachment_row['filepath'] == $casa->main_photo)) { if (!$casaService->delAttachment($casa_id, $attachment_row['id'])) { db_error("删除默认图片失败!"); } $mainAttachmentId = $attachmentDao->addSimple($casa->main_photo); if (!$mainAttachmentId) { db_error("添加默认图片失败!"); } if (!$casaDao->addPhoto($casa_id, $mainAttachmentId)) { db_error("关联民宿和默认图片失败!"); } } // else 跟之前的图片一样,不需要update } else {