Hey everyone,
I'm currently working on a project where I need to set MySQL variables using MySQLi, not PHP variables. I've been trying to find a solution, but I haven't had much luck so far.
To provide some context, I have a PHP script that connects to a MySQL database using MySQLi. Within this script, I need to set a few MySQL variables like "max_allowed_packet" and "wait_timeout" before executing my queries.
I know how to set these variables using regular SQL queries, but I specifically need to achieve this using MySQLi. I want to ensure that the changes I make to these variables are applied only to the current MySQLi connection and not affect other connections to the same database.
I've tried searching online, but most of the examples I found were related to using PHP variables to set MySQL variables, which is not what I need.
If anyone has any experience or knowledge on how to accomplish this task using MySQLi, I would greatly appreciate your assistance. Any guidance or example code would be extremely helpful.
Thank you all in advance for your help!

Hey there!
I've encountered a similar situation before, where I needed to set MySQL variables using MySQLi. Fortunately, I found a way to accomplish this.
To set MySQL variables using MySQLi, you can utilize the `query()` method of the MySQLi connection object. Here's an example code snippet to illustrate how it can be done:
In the above code, make sure to replace `<desired_value>` with the actual value you want to set for each variable.
By using `@@global` in the query, you are changing the value globally for MySQL, affecting all connections. On the other hand, using `@@session` sets the value only for the current MySQLi connection. So, keep that in mind depending on your requirements.
I hope this helps you achieve your goal of setting MySQL variables using MySQLi. If you have any further questions, feel free to ask. Good luck with your project!