Bug Report #2365
Indexes for _object are not loaded properly at ORM from object returned from database
| Status: | Closed | Start date: | 11/22/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | Modules:Database | |||
| Target version: | v3.0.3 | |||
| Resolution: | fixed | Points: |
Description
Now the database driver returns an array of associative arrays when the method list_columns is called. This change has not taken into account when the Method ORM::clear() is called (it gets called at __construct method). The variable $values below does not get the right indexes (they are in the form of 0,1,2,3,4... instead of column_name1, column_name2, column_name3...). _table_columns was set at reload_columns from the result of the list_columns method. Because the variable $values has the wrong indexes, the variable _object will result having wrong indexes as well when calling _load_values
/**
* Unloads the current object and clears the status.
*
* @chainable
* @return ORM
*/
public function clear()
{
// Create an array with all the columns set to NULL
$values = array_combine(array_keys($this->_table_columns), array_fill(0, count($this->_table_columns), NULL));
// Replace the object and reset the object status
$this->_object = $this->_changed = $this->_related = array();
// Replace the current object with an empty one
$this->_load_values($values);
$this->_reset();
return $this;
}
To me, either the variable $values is cleaned to have the right indexes or the database drivers return an array with the column names as indexes and their corresponding associative arrays with the rest of the information.
public function list_columns($table, $like = NULL)
{
...
$columns[$row['Field']] = $column;
}
return $columns;
}
Instead of
public function list_columns($table, $like = NULL)
{
...
$columns[] = $column;
}
return $columns;
}
Thanks,
Nano.
Related issues
History
Updated by Isaiah DeRose-Wilson about 2 years ago
- Category set to Modules:Database
- Status changed from New to Assigned
- Assignee set to Isaiah DeRose-Wilson
- Target version set to v3.0.2
Fixed in abb7e55f2...
Updated by Isaiah DeRose-Wilson about 2 years ago
- Status changed from Assigned to Resolved
- Resolution set to fixed
Updated by Woody Gilk about 2 years ago
- Status changed from Resolved to Closed
Updated by Woody Gilk about 2 years ago
- Target version changed from v3.0.2 to v3.0.3