2009-04-15 16:11:49 |
Sander van Schouwenburg (Sandworm) |
description |
When using AutoRecord::_db_join_one() for a left join (default) and the right side doesn't exist, the key will be overwritten with NULL values. Example:
Table1:
+--+-----+
|id|name1|
| 1|foo1 |
| 2|foo2 |
+--+-----+
Table2:
+--+-----+
|id|name2|
| 1|bar1 |
+--+-----+
> SELECT t1.id, t1.name, t2.id, t2.name FROM table1 t1 LEFT JOIN table2 t2 ON (t1.id = t2.id)
+--+-----+--+-----+
|id|name1|id|name2|
+--+-----+--+-----+
| 1|foo1 | 1|bar1 |
| 2|foo2 | | |
+--+-----+--+-----+
This will result in the following data structure:
$data = array(
array(
'id' => 1,
'name1' => 'foo1',
'name2 => 'bar1',
),
array(
'id' => NULL
'name1' => 'foo1',
'name2' => NULL
),
)
This is because the second 'id' overwrites the first one. |
When using AutoRecord::_db_join_one() for a left join (default) and the right side doesn't exist, the key will be overwritten with NULL values. Example:
Table1:
+--+-----+
|id|name1|
| 1|foo1 |
| 2|foo2 |
+--+-----+
Table2:
+--+-----+
|id|name2|
| 1|bar1 |
+--+-----+
> SELECT t1.id, t1.name, t2.id, t2.name FROM table1 t1 LEFT JOIN table2 t2 ON (t1.id = t2.id)
+--+-----+--+-----+
|id|name1|id|name2|
+--+-----+--+-----+
| 1|foo1 | 1|bar1 |
| 2|foo2 | | |
+--+-----+--+-----+
This will result in the following data structure:
$data = array(
array(
'id' => 1,
'name1' => 'foo1',
'name2 => 'bar1',
),
array(
'id' => NULL
'name1' => 'foo2',
'name2' => NULL
),
)
This is because the second 'id' overwrites the first one. |
|