mysql - Get last_inserted_id - PHP - Wordpress -


is there way insert data in 2 tables @ same time , @ same moment id first table , insert second table in field named user_id let's say. tried it's not working. missing something? want because need have same ids of same records in 2 tables make update. thanks.

global $current_user; get_currentuserinfo(); $user_id = $current_user->id; $table = 'tst_test'; $data = array(            'user_id' => $user_id,            'username' => $_post['fname'],            'email' => $_post['email'],            'telefon' => $_post['phone_number'] );  $format = array('%s','%s', '%s', '%s');  $send_data = $wpdb->insert($table, $data, $format); 

you can call $wpdb->insert_id after $wpdb->insert(_), return last inserted id of the object, can use same second record.

for more information on db operations of wordpress


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -