I write plugin and use in my code this function:
mysqli_multi_query($wpdb->dbh, $sql_trigger);. It's not hard to guess that on some hosting systems this function works correctly, but on some it produces the following error:
Warning: mysqli_multi_query() expects parameter 1 to be mysqli, resource given in /home/blah/blah.com/www/wp-content/plugins/blah/blah.php on line xxx
Question: how do I determine which type of database is used on the hosting and then correctly execute my query to the database?
Notice: My query to the database contains the following code:
CREATE TRIGGER `blah_set_current_time_and_date_values` BEFORE INSERT ON $table_name FOR EACH ROW BEGIN SET NEW.date_visited = DATE_FORMAT(NOW(), '%d-%m-&Y'); SET NEW.time_visited = TIME_FORMAT(NOW(), '%H:%i:%s'); END;
That's why I decided to use
mysqli_multi_query(), since I do not know how else to execute this query. Also, I tried use
$wpdb->query($sql_string);, but in this case WP returned error:
[Trigger already exists]. Although it does not exactly exist at that time, I delete it manually using
DROP TRIGGER IF EXISTS wordpress_rezart_statistics_set_current_time_and_date_values.