note 83884 added to function.mysql-query

From: Date: Mon, 16 Jun 2008 22:28:03 +0000
Subject: note 83884 added to function.mysql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-140516@lists.php.net to get a copy of this message
Dunno if is it a bug but when you are working with replications servers and work with multiple databases queries if you don't select the database it will only insert,update,delete into the master and bypass the slave, I think it its because it doesn't insert the sql on the binary log so the work around its to just call mysql_select_db MYSQL : 5.0.51a-log PHP: 5.2.6 Example: <?php #Inserts only to master $link=mysql_connect('host','user','pass'); $sql ="INSERT INTO mysql.host (host) VALUES ('localhost');" var_dump(mysql_query($sql,$link)); #The Working Way Master - Slave $link2=mysql_connect('host','user','pass'); $select_db = mysql_select_db('mysql', $link2); var_dump(mysql_query($sql,$link2)); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 189.152.13.110 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-query.php Edit -- https://master.php.net/note/edit/83884 Del: integrated -- https://master.php.net/note/delete/83884/integrated Del: useless -- https://master.php.net/note/delete/83884/useless Del: bad code -- https://master.php.net/note/delete/83884/bad+code Del: spam -- https://master.php.net/note/delete/83884/spam Del: non-english -- https://master.php.net/note/delete/83884/non-english Del: in docs -- https://master.php.net/note/delete/83884/in+docs Del: other reasons-- https://master.php.net/note/delete/83884 Reject -- https://master.php.net/note/reject/83884 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140516) next »