Is it good practice to use wpdb->query() function?


I am using custom php code to perform data insertion, deletion, updating and other tasks. I am able to insert data into a table in two different ways,

$wpdb->insert($table_name, array('id' => NULL, 'name' => '$name', 'email' => '$email', 'city' => '$city'));


$sql = "INSERT INTO $table_name VALUES('', '$name', '$email', '$city')";

Is it a good practice to use wpdb->query() function each time by passing my query to the function instead of using the dedicated functions like insert() and delete() etc? If not, what are the disadvantages of this approach?

Asmat Ali 1 month 0 Answers 8 views 0

Leave an answer