Permalink
Browse files

Preload fix, closes #211

  • Loading branch information...
1 parent eac266a commit 5f644433ef60376ae1b7ea82377364e6953265e1 @gabordemooij committed Nov 16, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 RedBean/OODB.php
View
@@ -894,10 +894,11 @@ public function preload($beans, $types) {
$field = (is_numeric($key)) ? $type : $key;
$ids = array();
foreach($beans as $bean) {
- $id = $bean->{$field.'_id'};
- $ids[$id] = $id;
- if (!isset($map[$id])) $map[$id] = array();
- $map[$id][] = $bean;
+ if($id = $bean->{$field.'_id'}){
+ $ids[$id] = $id;
+ if (!isset($map[$id])) $map[$id] = array();
+ $map[$id][] = $bean;
+ }
}
$parents = $this->batch($type,$ids);
foreach($parents as $parent) {

0 comments on commit 5f64443

Please sign in to comment.