Commit 06f3adb3 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Database.php: sql(..., ROW_IMPLODE_ALL,...) have been confused by columns with...

Database.php: sql(..., ROW_IMPLODE_ALL,...) have been confused by columns with identical columnnames (MYSQLI_ASSOC). Has been fixed now by using MYSQLI_NUM.
parent dde9e8e6
......@@ -483,7 +483,7 @@ class Database {
switch ($mode) {
case ROW_IMPLODE_ALL:
$str = "";
foreach ($this->mysqli_result->fetch_all(MYSQLI_ASSOC) as $row) {
foreach ($this->mysqli_result->fetch_all(MYSQLI_NUM) as $row) {
$str .= implode($row);
}
return $str;
......
......@@ -119,6 +119,18 @@ class DatabaseTest extends AbstractDatabaseTest {
// Check Implode 0 record
$data = $this->db->sql('SELECT * FROM Person WHERE id=0 ORDER BY id LIMIT 2', ROW_IMPLODE_ALL);
$this->assertEquals('', $data);
$data = $this->db->sql('SELECT "a", "b", "c"', ROW_IMPLODE_ALL);
$this->assertEquals('abc', $data);
// Multiple columns with same columnname
$data = $this->db->sql('SELECT "a", "b", "a"', ROW_IMPLODE_ALL);
$this->assertEquals('aba', $data);
// Multiple columns with same columnname
$data = $this->db->sql('SELECT id, name, firstname, name, id FROM Person', ROW_IMPLODE_ALL);
$this->assertEquals('1DoeJohnDoe12SmithJaneSmith2', $data);
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment