Ticket #1409: seagull.patch_pear

File seagull.patch_pear, 0.9 kB (added by zeph1r, 5 years ago)

PEAR/sqlite table aliasing BUGfix

Line 
1 Index: lib/pear/DB/sqlite.php
2 ===================================================================
3 --- lib/pear/DB/sqlite.php      (revision 163)
4 +++ lib/pear/DB/sqlite.php      (working copy)
5 @@ -354,6 +354,19 @@
6          }
7          if ($fetchmode & DB_FETCHMODE_ASSOC) {
8              $arr = @sqlite_fetch_array($result, SQLITE_ASSOC);
9 +
10 +            // BUG FIX: column name 'b.name' returned instead of 'name'
11 +            $tmp = array();
12 +            if (is_array($arr))
13 +            foreach($arr as $index => $content)
14 +                if( ($cursor = strrchr($index,'.')) !== false ) {
15 +                    $rindex = substr($cursor,1);
16 +                    $tmp[$rindex] = $content;
17 +                } else {
18 +                    $tmp[$index] = $content;
19 +                }
20 +            $arr = $tmp;
21 +
22              if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
23                  $arr = array_change_key_case($arr, CASE_LOWER);
24              }