Home > DeveloperSection > Forums > connection with sql command
Garry Winogrand
Garry Winogrand

Total Post:24

Points:168
Posted on    July-09-2013 3:17 AM

 MYSQL MYSQL 
Ratings:


 1 Reply(s)
 916  View(s)
Rate this:
Hi Expert!

How do I execute a command as and when a new mysql connection is established from php?

$con=mysqli_connect("localhost","root","","gts");

In the above example, I need to pass set sql command :

sql_log_bin = 0

This will make sure that the commands executed by this connection will not be written to binary log. I have another "normal" connection that will work as usual and write all the commands to binary log.

In other words I need 2 connections to mysql one with disabled binary logging. I should be able to decide which one to use. How is it done in PHP?

Thanks in advance. 


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    July-09-2013 4:41 AM

Hi,

First create two connections.

$con1=mysqli_connect("localhost","root","","gts");
$con2=mysqli_connect("localhost","root","","gts");

Then on one of them disable your binlog

mysqli_query($con1, "SET sql_log_bin = 0");

I Hope it helpful for you.

Modified On Jul-09-2013 04:42:34 AM

Don't want to miss updates? Please click the below button!

Follow MindStick