문제

I am running an fgetcsv query to import a bunch of data from a CSV into WordPress.

I am wondering how I can start an auto increment from a certain number, for example, from 1000 onwards.

$import1="INSERT into wp_postmeta (meta_id,post_id,meta_key,meta_value) values(',',',','first_name','$data[1]')";

This is an example of the code. the meta_id should use a normal auto increment, but the post_id I want to start from a certain number.

How would I accomplish this?

도움이 되었습니까?

해결책

To set the starting value for an auto increment field, you can use alter table

ALTER TABLE wp_postmeta AUTO_INCREMENT = 1000;

As far as I know, it is not possible to have two auto incrementing fields on the same table in mysql, so you have to do it progamatically yourself (eg with a trigger)

다른 팁

To change the AUTO_INCREMENT value on the table:

ALTER TABLE wp_postmeta AUTO_INCREMENT = 1000;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top