在Zblog有文章ID连续的插件,而Emlog没有,所以就需要手动修改,使得删除文章断掉的ID可以自动增补。

路径在include/model/log_model.php,EMLOG的原始代码如下:

/**
* 添加文章、页面
*
* @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;
}
把他修改为以下代码:

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;
}
这样就可以完美解决EMLOG文章断ID的问题了!


本文最后更新于2018-4-21,已超过一个月没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!
[百度已收录] | [360已收录] | [搜狗已收录]