[php-src] Issue #20300: SQLite3Result::fetchArray Doesn't Handle Join Statement Properly
| From: | loay-ali | Date: | Sun, 26 Oct 2025 07:10:33 +0000 |
| Subject: | [php-src] Issue #20300: SQLite3Result::fetchArray Doesn't Handle Join Statement Properly | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251121@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/20300
Author: loay-ali
When i tried using ( ``
join`` ) statement for fetching data , sqlite3 tend to overwrite
the column name if it appears in the other table
* eg:
``table-a``
| ID | Name | Foreign_id
|:---|:---:|---:|
|1| bar|2|
``table-b``
| ID | Name |
|:---|---:|
|2| foo |
*When i try to join them*
```sql
SELECT * FROM table-a a JOIN table-b b ON(a.foreign_id=b.id)
```
i get the result as follows
```php
[
array(
'ID' => 2,
'name' => 'foo',
'foreign_id' => 2
)
]
```
i suggest prefixing the columns names with the table aliases name to clarify and avoid overwriting
So the result would be like this
```php
[
array(
'a.ID' => 1,
'a.name' => 'bar',
'a.Foreign_id' => 2,
'b.ID' => 2,
'b.name' => 'foo'
)
]
```
*thanks in advance*
From manual page: https://php.net/sqlite3result.fetcharray
---