j4mie / idiorm

A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.
http://j4mie.github.com/idiormandparis/
2.01k stars 369 forks source link

Illegal offset type in idiorm.php on line 2028 #233

Closed chihlongliu-zz closed 7 years ago

chihlongliu-zz commented 10 years ago

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'.

lrlopez commented 10 years ago

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

lrlopez commented 10 years ago

@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.

treffynnon commented 7 years ago

Fix merged in develop. Thanks!