emlog531常用的写表操作

写入文章:

$sql="INSERT INTO emlog_blog (title,date,content,excerpt,alias,author,sortid,type,top,sortop,hide,checked,allow_remark,password) VALUES ('标题',1486002032,'文章内容','','',1,3,'blog','n','n','n','y','y','')";
mysql_query($sql,$con);
更新文章:
$sql="UPDATE emlog_blog SET title = '更新了标题'WHERE gid = 2";
mysql_query($sql,$con);
写入附件:
$sql="INSERT INTO emlog_attachment (blogid,filename,filesize,filepath,addtime,width,height,mimetype,thumfor) VALUES (2,'testfilename',6666,'.baidu.com/apple.zip',".time().",0,0,'file/zip',0)";
mysql_query($sql,$con);
写入标签:
$sql = "SELECT * FROM emlog_tag WHERE tagname = '新的标签'";
【emlog531常用的写表操作】$result = mysql_query($sql,$con);
if(mysql_num_rows($result)){
$sql="UPDATE emlog_tag SET gid=concat(gid,'9,') WHERE tagname = '新的标签'";
mysql_query($sql,$con);
}else{
$sql="INSERT INTO emlog_tag (tagname,gid) VALUES ('新的标签',',1,')";
mysql_query($sql,$con);
}
写入评论:
$sql="INSERT INTO ".$prefix."comment (gid,pid,date,poster ,comment,mail,url,ip,hide) VALUES ({$gid},{$pid},{$date},'{$poster}','{$comment}','{$mail}','{$url}','{$ip}','n')";
mysql_query($sql,$con);

    推荐阅读