diff options
author | Davey Shafik <me@daveyshafik.com> | 2017-01-08 16:15:33 -0800 |
---|---|---|
committer | Davey Shafik <me@daveyshafik.com> | 2017-01-08 16:15:33 -0800 |
commit | 8fee9378cf84a89c19a39042d8ce06c5850caf84 (patch) | |
tree | e4d827a4f96547992c14089c30fcddd1d774f840 | |
parent | f3a6f930bd25fb08554486994637a02139f8ddca (diff) | |
download | php7-mysql-shim-8fee9378cf84a89c19a39042d8ce06c5850caf84.zip php7-mysql-shim-8fee9378cf84a89c19a39042d8ce06c5850caf84.tar.gz php7-mysql-shim-8fee9378cf84a89c19a39042d8ce06c5850caf84.tar.bz2 |
Add third argument to `mysql_db_name()`
Fixes #23
-rw-r--r-- | lib/mysql.php | 10 | ||||
-rw-r--r-- | tests/MySqlShimTest.php | 17 |
2 files changed, 17 insertions, 10 deletions
diff --git a/lib/mysql.php b/lib/mysql.php index f561381..f2908a0 100644 --- a/lib/mysql.php +++ b/lib/mysql.php @@ -535,7 +535,7 @@ namespace { return mysqli_set_charset(\Dshafik\MySQL::getConnection($link), $charset); } - function mysql_db_name($result, $row) + function mysql_db_name($result, $row, $field = 0) { if (\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) { // @codeCoverageIgnoreStart @@ -543,8 +543,8 @@ namespace { // @codeCoverageIgnoreEnd } - // Alias as per http://lxr.php.net/xref/PHP_5_6/ext/mysql/php_mysql.c#319 - return mysql_result($result, $row, 'Database'); + // Alias as per https://github.com/php/php-src/blob/PHP-5.6/ext/mysql/php_mysql.c#L319 + return mysql_result($result, $row, $field); } function mysql_tablename($result, $row) @@ -621,9 +621,9 @@ namespace { return mysql_list_fields($databaseName, $tableName, $link); } - function mysql_dbname($result, $row) + function mysql_dbname($result, $row, $field = 0) { - return mysql_db_name($result, $row); + return mysql_db_name($result, $row, $field); } function mysql_table_name($result, $row) diff --git a/tests/MySqlShimTest.php b/tests/MySqlShimTest.php index 3cd86e2..7ffb704 100644 --- a/tests/MySqlShimTest.php +++ b/tests/MySqlShimTest.php @@ -840,11 +840,6 @@ class MySqlShimTest extends \PHPUnit_Framework_TestCase mysql_escape_string("'\0\032\r\n\"\\"); } - public function tearDown() - { - @mysql_close(); - } - public function test_mysql_select_db() { $this->getConnection(); @@ -866,6 +861,18 @@ class MySqlShimTest extends \PHPUnit_Framework_TestCase $this->assertFalse(mysql_select_db('nonexistent')); } + public function test_mysql_db_name() + { + $conn = $this->getConnection(); + $dbs = mysql_list_dbs(); + $this->assertEquals('information_schema', mysql_db_name($dbs, 0)); + } + + public function tearDown() + { + @mysql_close(); + } + public static function setUpBeforeClass() { error_reporting(E_ALL & ~E_DEPRECATED); |