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'));
and
$sql = "INSERT INTO $table_name VALUES('', '$name', '$email', '$city')";
$wpdb->query($sql);
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?