网络神采的存储过程使用



存储过程添加wordpress文章,前提是:插入过程中,无后台操作,否则会自动保存 等新建其他元素,导致wp_posts的ID紊乱。

20171012203216

DELIMITER $$

USE `wordpress`$$

DROP PROCEDURE IF EXISTS `addPost2`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `addPost2`($title TEXT CHARACTER SET utf8,$content LONGTEXT CHARACTER SET gbk,$times DATETIME,$cid INT)
BEGIN
DECLARE thisid INT;
SELECT MAX(`ID`)+1 FROM `wp_posts` INTO thisid;
INSERT INTO `wp_posts` (`ID`,`post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(thisid,1,$times, $times, $content, $title, ”, ‘publish’, ‘open’, ‘open’, ”, thisid, ”, ”, $times, $times, ”, 0, thisid, 0, ‘post’, ”, 0);
INSERT INTO wp_term_relationships VALUES(thisid,$cid,0);
END$$

DELIMITER ;

CALL addPost2(‘中文’,’English Content’,’2017-10-10′,1)

 

然后选择设置 列名称参数绑定。

20171012203256