修复数据库更新错误
This commit is contained in:
parent
f61b0d450c
commit
f45c9c9321
|
@ -8,6 +8,7 @@ class Admin_WatermdController extends Zend_Controller_Action
|
|||
$this->messenger=$this->_helper->getHelper('FlashMessenger');
|
||||
$this->view->messages = $this->messenger->getMessages();
|
||||
$this->wdb=Zend_Db::factory($this->view->config->waterdb);
|
||||
set_time_limit(0);
|
||||
}
|
||||
function postDispatch()
|
||||
{
|
||||
|
@ -303,23 +304,26 @@ class Admin_WatermdController extends Zend_Controller_Action
|
|||
$this->view->test=$this->contactReplace($formdata["testxml"],$formdata);
|
||||
} elseif (isset($formdata["submit"]))
|
||||
{
|
||||
$sql="select uuid,data from metadata where istemplate = 'n'";
|
||||
$sql="select uuid,data from metadata where istemplate = 'n' and data like '%".$formdata['oldname']."%'";
|
||||
$rows=$this->wdb->fetchAll($sql);
|
||||
foreach($rows as $k=>$row)
|
||||
$this->view->deal=array();
|
||||
foreach($rows as $row)
|
||||
{
|
||||
//do the replace
|
||||
$new_data=$this->contactReplace($row["data"],$formdata);
|
||||
//防止正则错误
|
||||
//防止错误
|
||||
if (!empty($new_data))
|
||||
{
|
||||
$sql="update metadata set data=? where uuid=?";
|
||||
$this->wdb->query($sql,array($new_data,$uuid));
|
||||
$sql="update metadata set data=? where uuid='".$row['uuid']."'";
|
||||
if ($this->wdb->exec($this->wdb->quoteInto($sql,$new_data)))
|
||||
{
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($row['data']);
|
||||
$title=$dom->getElementsByTagName('resTitle')->item(0)->nodeValue;
|
||||
$deal['uuid']=$uuid;
|
||||
$deal['uuid']=$row['uuid'];
|
||||
$deal['title']=$title;
|
||||
$this->view->deal[]=$deal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,19 +23,6 @@
|
|||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->deal) : ?>
|
||||
<div id="mdlist">
|
||||
已处理数据:
|
||||
<?php foreach ($this->deal as $deal): ?>
|
||||
<ul>
|
||||
<li>UUID:<?php echo $deal['uuid']; ?></li>
|
||||
<li><a href="/heihe/<?= $deal['uuid']; ?>"><?= $deal['title']; ?></a></li>
|
||||
</ul>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<form enctype="application/x-www-form-urlencoded" action="" method="post">
|
||||
<label>被替换者姓名:</label>
|
||||
<input type="text" name="oldname" value="<?= $this->formdata['oldname'] ?>">
|
||||
|
@ -43,17 +30,29 @@
|
|||
<li><label>姓名:</label><input type="text" name="name" value="<?= $this->formdata['name'] ?>"></li>
|
||||
<li><label>单位:</label><input type="text" name="unit" value="<?= $this->formdata['unit'] ?>"></li>
|
||||
<li><label>地址:</label><input type="text" name="delpoint" value="<?= $this->formdata['delpoint'] ?>"></li>
|
||||
<li><label>City:</label><input type="text" name="city" value="<?= $this->formdata['city'] ?>"></li>
|
||||
<li><label>Province:</label><input type="text" name="adminarea" value="<?= $this->formdata['adminarea'] ?>"></li>
|
||||
<li><label>Country:</label><input type="text" name="country" value="<?= $this->formdata['country'] ?>"></li>
|
||||
<li><label>城市:</label><input type="text" name="city" value="<?= $this->formdata['city'] ?>"></li>
|
||||
<li><label>省份:</label><input type="text" name="adminarea" value="<?= $this->formdata['adminarea'] ?>"></li>
|
||||
<li><label>国家:</label><input type="text" name="country" value="<?= $this->formdata['country'] ?>"></li>
|
||||
<li><label>邮编:</label><input type="text" name="postcode" value="<?= $this->formdata['postcode'] ?>"></li>
|
||||
<li><label>电话:</label><input type="text" name="voicenum" value="<?= $this->formdata['voicenum'] ?>"></li>
|
||||
<li><label>邮箱:</label><input type="text" name="email" value="<?= $this->formdata['email'] ?>"></li>
|
||||
</fieldset>
|
||||
<label>测试XML数据</label>
|
||||
<textarea name="testxml" rows="10" cols="80"><?= $this->formdata['testxml'] ?></textarea>
|
||||
<li><input type="submit" name="test" id="test" value="测试"> <input type="submit" name="submit" value="全部运行(危险操作!请先测试)"></li>
|
||||
<li><input type="submit" name="test" id="test" value="测试"> <input type="submit" id="submit" name="submit" value="全部运行(危险操作!请先测试)"></li>
|
||||
</form>
|
||||
<?php if ($this->deal) : ?>
|
||||
<div id="mdlist">
|
||||
已处理数据:
|
||||
<?php foreach ($this->deal as $deal): ?>
|
||||
<ul>
|
||||
<li>UUID:<?php echo $deal['uuid']; ?></li>
|
||||
<li><a href="/data/<?= $deal['uuid']; ?>"><?= $deal['title']; ?></a></li>
|
||||
</ul>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ($this->test) : ?>
|
||||
<div>测试结果:<br />
|
||||
<?= $this->escape($this->test) ?>
|
||||
|
|
Loading…
Reference in New Issue