Abubakar Abubakar - 1 month ago 8
MySQL Question

How to check if new rows is insert in specific table

My table name is pm. I have two questions.


  1. How can I check if new rows is insert this table(using wpdb query)?

  2. How to get the inserted rows from table (using wpdb query)?


Sam Sam
Answer
$wpdb->insert('table', $arrayData); 

this will return true if it successfully added to your table and false if failed to add to table due to some error in query

to get the last inserted record id you can use

$wpdb->insert_id

which will return last record's id

more details on $wpdb is here https://codex.wordpress.org/Class_Reference/wpdb#INSERT_row