summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/mysql.php10
-rw-r--r--tests/MySqlShimTest.php17
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);