NYCPHP Meetup

NYPHP.org

[nycphp-talk] OO & database connections

putamare jeffknight at mac.com
Fri Jul 16 12:37:34 EDT 2004


I have confirmed that this is not true for mysqli_, if you have

$dbcon1 = new mysqli($h,$u,$p);
$dbcon2 = new mysqli($h,$u,$p);

$dbcon1->select_db('db1');
$dbcon2->select_db('db2');

if ( $result = $dbcon1->query( 'SHOW TABLES' )) :
	while ($row = $result->fetch_row())  echo $row[0] . "<br/>";
	$result->close();
endif;

Will give you the tables in db1



On Jul 15, 2004, at 7:57 PM, Chris Snyder wrote:

> I didn't believe this when I first read it, but can confirm:
>
> $dbcon1 = mysql_connect( $h, $u, $p );
> mysql_select_db( 'clew', $dbcon1 );
>
> $dbcon2 = mysql_connect( $h, $u, $p );
> mysql_select_db( 'chxo', $dbcon2 );
>
> $result = mysql_query( "show tables",  $dbcon1 );
> while ( $record = mysql_fetch_array( $result ) ) {
>  print $record[0]."<br />";
> }
>
> ... will show the tables in the "second" database, even though the 
> query was sent via the "first" connection.
>
> Weird.

Jeff Knight
putamare not junk at putamare.net




More information about the talk mailing list