예제 #1
0
 /**
  * 更新内容
  *
  * @access public
  * @param array $content 内容数组
  * @param Typecho_Db_Query $condition 更新条件
  * @return integer
  */
 public function update(array $content, Typecho_Db_Query $condition)
 {
     /** 首先验证写入权限 */
     if (!$this->isWriteable(clone $condition)) {
         return false;
     }
     /** 构建更新结构 */
     $preUpdateStruct = array('title' => empty($content['title']) ? NULL : htmlspecialchars($content['title']), 'order' => empty($content['order']) ? 0 : intval($content['order']), 'text' => empty($content['text']) ? NULL : $content['text'], 'template' => empty($content['template']) ? NULL : $content['template'], 'type' => empty($content['type']) ? 'post' : $content['type'], 'status' => empty($content['status']) ? 'publish' : $content['status'], 'password' => empty($content['password']) ? NULL : $content['password'], 'allowComment' => !empty($content['allowComment']) && 1 == $content['allowComment'] ? 1 : 0, 'allowPing' => !empty($content['allowPing']) && 1 == $content['allowPing'] ? 1 : 0, 'allowFeed' => !empty($content['allowFeed']) && 1 == $content['allowFeed'] ? 1 : 0, 'parent' => empty($content['parent']) ? 0 : intval($content['parent']));
     $updateStruct = array();
     foreach ($content as $key => $val) {
         if (array_key_exists($key, $preUpdateStruct)) {
             $updateStruct[$key] = $preUpdateStruct[$key];
         }
     }
     /** 更新创建时间 */
     if (!empty($content['created'])) {
         $updateStruct['created'] = $content['created'];
     }
     $updateStruct['modified'] = $this->options->gmtTime;
     /** 首先插入部分数据 */
     $updateCondition = clone $condition;
     $updateRows = $this->db->query($condition->update('table.contents')->rows($updateStruct));
     /** 更新缩略名 */
     if ($updateRows > 0 && isset($content['slug'])) {
         $this->applySlug(empty($content['slug']) ? NULL : $content['slug'], $condition);
     }
     return $updateRows;
 }
예제 #2
0
파일: Credits.php 프로젝트: Jsechoo/sisome
 public function update(array $rows, Typecho_Db_Query $condition)
 {
     return $this->db->query($condition->update('table.creditslog')->rows($rows));
 }
예제 #3
0
파일: Metas.php 프로젝트: dccecc/typecho
 /**
  * 更新记录
  *
  * @access public
  * @param array $options 记录更新值
  * @param Typecho_Db_Query $condition 更新条件
  * @return integer
  */
 public function update(array $options, Typecho_Db_Query $condition)
 {
     return $this->db->query($condition->update('table.metas')->rows($options));
 }