j4mie/idiorm

Illegal offset type in idiorm.php on line 2028

chihlongliu-zz opened this issue · 3 comments

When using compound keys with id_column_overrides, I get some illegal offset type warnings with PHP 5.3.3. On line 2026, taking the array slice of the column still results in an array (with the single element that was sliced out from $column). Using $column[0] = $column seems to fix this problem.

However, when I run it, $db->lastInsertId() is undefined, and even if I hard code $this->_data[$column] to a set value (e.g. 30), saving it won't set the id value to 30. (actually, if creating a new record in this context, the database autoincrements the value correctly, so I'm not sure if lastInsertId() is even needed)

Lastly, I also ran into the illegal offset type problem on line 1892 (under _get_id_column_name()). The current workaround I found was to explicitly define in id_column_overrides all id columns for all tables, even if the table only had a single primary key with name 'id'.

Thanks for reporting! I'll take a look into these issues ASAP

@chihlongliu, please have a look into PR #235

Can you test this patch against your code? It should fix your problems. If it doesn't, just drop me a line.

Fix merged in develop. Thanks!