EMLOG文章GID断号自动补充教程
- A
EMLOG在删除文章后GID就会断掉,现在只需要简单修改一下代码,后面新增文章的时候就会优先选择断掉的文章ID。
路径在include/model/log_model.php
原始代码如下:
/** * 添加文章、页面 * * @param array $logData * @return int */ function addlog($logData) { $kItem = array(); $dItem = array(); foreach ($logData as $key => $data) { $kItem[] = $key; $dItem[] = $data; } $field = implode(',', $kItem); $values = "'" . implode("','", $dItem) . "'"; $this->db->query("INSERT INTO " . DB_PREFIX . "blog ($field) VALUES ($values)"); $logid = $this->db->insert_id(); return $logid; }
修改为:
/** * 添加文章、页面 * * @param array $logData * @return int */ function addlog($logData) { $kItem = array(); $dItem = array(); foreach ($logData as $key => $data) { $kItem[] = $key; $dItem[] = $data; } $field = implode(',', $kItem); $values = "'" . implode("','", $dItem) . "'"; $gidarr[0]='0'; $res = $this->db->query("SELECT gid From " . DB_PREFIX . "blog ORDER BY gid ASC"); while ($row = $this->db->fetch_array($res)) { $gidarr[] = $row['gid']; } foreach($gidarr as $key=>$val){ if($key!=$val){ $field = 'gid,'.$field; $values = "'".$key."',".$values; break; } } $this->db->query("INSERT INTO " . DB_PREFIX . "blog ($field) VALUES ($values)"); $logid = $this->db->insert_id(); return $logid; }
傲世》原创,转载请保留文章出处。
本文链接:https://www.recho.cn/53.html
如您对本文章内容有所疑问、反馈或补充,欢迎通过邮箱:admin@h2fast.cn 联系我们!
版权声明:若无特殊注明,本文为《正文到此结束