Jump to content

Find insert id for CURRENT insert


bschultz

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.