- Timestamp:
- 03/03/10 13:45:21 (5 months ago)
- Files:
-
- fORMRelated.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
fORMRelated.php
r745 r753 Hide Line Numbers 6 6 * constraints. 7 7 * 8 * @copyright Copyright (c) 2007-20 09Will Bond8 * @copyright Copyright (c) 2007-2010 Will Bond 9 9 * @author Will Bond [wb] <will@flourishlib.com> 10 10 * @license http://flourishlib.com/license … … 13 13 * @link http://flourishlib.com/fORMRelated 14 14 * 15 * @version 1.0.0b23 15 * @version 1.0.0b24 16 * @changes 1.0.0b24 Added the ability to associate a single record via primary key [wb, 2010-03-03] 16 17 * @changes 1.0.0b23 Fixed a column aliasing issue with SQLite [wb, 2010-01-25] 17 18 * @changes 1.0.0b22 Fixed a bug with associating a non-contiguous array of fActiveRecord objects [wb, 2009-12-17] … … 104 105 $related_table = fORM::tablize($related_class); 105 106 106 if (!$record instanceof fActiveRecord) { 107 $record = new $related_class($record); 107 if ($record !== NULL) { 108 if (!$record instanceof fActiveRecord) { 109 $record = new $related_class($record); 110 } 111 $records = array($record); 112 } else { 113 $records = array(); 108 114 } 109 115 110 116 $schema = fORMSchema::retrieve($class); 111 $records = fRecordSet::buildFromArray($related_class, array($record));117 $records = fRecordSet::buildFromArray($related_class, $records); 112 118 $route = fORMSchema::getRouteName($schema, $table, $related_table, $route, 'one-to-one'); 113 119 … … 897 903 898 904 foreach ($routes as $route) { 899 $route_names[] = fORMSchema::getRouteNameFromRelationship(' one-to-one', $route);905 $route_names[] = fORMSchema::getRouteNameFromRelationship('*-to-one', $route); 900 906 } 901 907 … … 1628 1634 1629 1635 /** 1630 * Copyright (c) 2007-20 09Will Bond <will@flourishlib.com>1636 * Copyright (c) 2007-2010 Will Bond <will@flourishlib.com> 1631 1637 * 1632 1638 * Permission is hereby granted, free of charge, to any person obtaining a copy
