|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-04-26 11:49 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Mar 03 18:00:01 2026 UTC |
Description: ------------ The SHOW TABLES command doesn't work on the currently selected database, but on the last selected one, even if that one has been executed on a different connection handle. In the example code, replace "host", "user", "password" with host, user and password of your mysql server, and "test1", "test2" with two names of two different databases on your mysql server - they should contain tables with different names so you can detect a different listing. The same problem comes up with "SHOW INDEX FROM table" and "SHOW COLUMNS FROM table" :-( They always put out information from the second db... Exchanging mysql_connect with mysql_pconnect() doesn't change anything. php.ini is without surprise: [MySQL] mysql.allow_persistent = On mysql.max_persistent = -1 mysql.max_links = -1 mysql.default_port = mysql.default_socket = mysql.default_host = mysql.default_user = mysql.default_password = The configureline shouldn't be problem either: './configure' '--prefix=/httpd' '--with-config-file-path=/httpd/lib' '--with-apxs=/httpd/bin/apxs' '--with-informix=/informix' '--with-ttf' '--with-ftp' '--with-sfw' '--with-hyperwave' '--with-snmp' '--with-bz2' '--with-mime-magic' '--with-gdbm' '--with-inifile' '--with-flatfile' '--enable-bcmath' '--enable-calendar' '--enable-sockets' '--enable-dba' '--enable-wddx' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-trans-sid' '--enable-safe-mode' '--enable-memory-limit' '--enable-inline-optimization' '--enable-magic-quotes' '--with-zlib=yes' '--with-gd=yes' '--with-unixODBC=/usr/lib' '--with-jpeg-dir=/usr/lib' '--with-png-dir=/usr/lib' '--with-tiff-dir=/usr/lib' '--with-imap' '--with-ssl=/usr' '--with-imap-ssl=/usr' '--with-openssl=/usr' Reproduce code: --------------- function connect ($name) { $res = @mysql_connect ("host", "user", "password"); mysql_select_db ($name, $res); return $res; } function list_tables ($db) { if ($retv = @mysql_query ("SHOW TABLES", $db)) { $res = array(); while ($v = @mysql_fetch_assoc ($retv)) { foreach ($v as $idx => $name) { $s = $name; break; } $res[] = $s; } @mysql_free_result ($retv); } return $res; } $db1 = connect ("test1"); $db2 = connect ("test2"); $qr1 = list_tables ($db1); $qr2 = list_tables ($db2); @mysql_close ($db1); @mysql_close ($db2); var_dump ($qr1); var_dump ($qr2); Expected result: ---------------- List of names of tables in database "test1" and "test2" Actual result: -------------- List of names of tables in database "test2" - twice