forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RFC: expose mysql_connect_with_db() to PHP userland
Summary: The mysql protocol allows the selection of an initial database on connect time. We currently have to call mysql_select_db() immediately after establishing a connection. This change will allow us to set the db at connect time, to avoid unnecessary round trips. Test Plan: I created a local instance of mysql and these databases: create database foo; create database bar; create table bar_table ( message varchar(64) ); insert into bar_table (message) values ('You selected from bar_table in bar db!'); create table foo_table ( message varchar(64) ); insert into foo_table (message) values ('You selected from foo_table in foo db!'); Then I ran this test code: $c = mysql_connect('127.0.0.1:3306', 'root'); echo $c . "<br/>"; mysql_select_db('foo') ."<br/>"; print_r( mysql_fetch_array(mysql_query('show tables'), $c) ); echo "<br/>"; print_r( mysql_fetch_array(mysql_query('select * from foo_table'), $c) ); echo "<hr/>"; $d = mysql_connect_with_db('127.0.0.1:3306', 'root', '', "bar"); echo $d . "<br/>"; print_r( mysql_fetch_array(mysql_query('show tables'), $d) ); echo "<br/>"; print_r( mysql_fetch_array(mysql_query('select * from bar_table'), $d) ); Expected result: Resource id facebook#1 Array ( [Tables_in_foo] => foo_table ) Array ( [message] => You selected from foo_table in foo db! ) Resource id facebook#2 Array ( [0] => bar_table ) Array ( [0] => You selected from bar_table in bar db! ) DiffCamp Revision: 138364 Reviewed By: macvicar Commenters: ps, rmcelroy, mcallaghan CC: hphp-diffs@lists, rmcelroy, ps, macvicar, mcallaghan, cbueno Revert Plan: OK
- Loading branch information
cbueno
authored and
macvicar
committed
Aug 1, 2010
1 parent
6e0d206
commit 329dca0
Showing
6 changed files
with
238 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.