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
Post a Comment