0 && !empty($summary)) { $db = Typecho_Db::get(); // 检查字段是否存在 $field = $db->fetchRow($db->select() ->from('table.fields') ->where('cid = ?', $postId) ->where('name = ?', 'description')); if ($field) { // 更新字段 $db->query($db->update('table.fields') ->rows(array('str_value' => $summary)) ->where('cid = ?', $postId) ->where('name = ?', 'description')); } else { // 插入新字段 $db->query($db->insert('table.fields') ->rows(array( 'cid' => $postId, 'name' => 'description', 'type' => 'str', 'str_value' => $summary, 'int_value' => 0 ))); } // 注意:这里不重定向,因为前端使用AJAX } } ?> footer(); ?>