bschultz Posted July 18, 2012 Share Posted July 18, 2012 I"m working on importing my existing website (with a custom cms) into a wordpress system. I'm trying to insert all of my current posts...and need to know what the insert id is for the WP system. I know that mysql_insert_id will get the key of the LAST query...but is there a way to get the id of the CURRENT query? Quote Link to comment https://forums.phpfreaks.com/topic/265915-find-insert-id-for-current-insert/ Share on other sites More sharing options...
Mahngiel Posted July 18, 2012 Share Posted July 18, 2012 You cannot get a current insert_id with standard ways. You could predict it by grabbing the last_id and adding one, but that's not guaranteed either. The best way to do it is to create a blank record when you're adding something and then updating that when you're finished. You could set the status of it to -1 or 9 or what-have-you so that abandoned entries are not picked up - and later run a small cron script that will remove all the abandoned posts. Quote Link to comment https://forums.phpfreaks.com/topic/265915-find-insert-id-for-current-insert/#findComment-1362518 Share on other sites More sharing options...
bschultz Posted July 18, 2012 Author Share Posted July 18, 2012 thanks...was trying to do this in one step...but that will work. Quote Link to comment https://forums.phpfreaks.com/topic/265915-find-insert-id-for-current-insert/#findComment-1362519 Share on other sites More sharing options...
bschultz Posted July 18, 2012 Author Share Posted July 18, 2012 OK...got that working. Now, I need to fix slashes. The old system (which I wrote a LONG time ago) used addslashes to the posts. When I import that into the new Wordpress Database...it has slashes echoed in everything. So, does anyone know where I can add STRIPSLASHES in the WP code (I'm VERY new to WP)... or how can I strip the slashes from my select...before I insert into the WP table? I tried to: $stripslashes= stripslashes($row['story']); But the insert failed at every quote in the original post. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/265915-find-insert-id-for-current-insert/#findComment-1362560 Share on other sites More sharing options...
bschultz Posted July 18, 2012 Author Share Posted July 18, 2012 got it... $slashes_title = stripslashes($row['headline']); $title = mysql_real_escape_string($slashes_title); $stripslashes= stripslashes($row['story']);; $story = mysql_real_escape_string($stripslashes); Quote Link to comment https://forums.phpfreaks.com/topic/265915-find-insert-id-for-current-insert/#findComment-1362566 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.