Changeset 154
- Timestamp:
- 10/19/09 12:07:00 (1 month ago)
- Files:
-
- 1 modified
-
trunk/class-abstractmodel.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/class-abstractmodel.php
r153 r154 12 12 * - $HeadURL$ 13 13 * @changelog 14 * - 2009-10-01 - new modelCollection::isEmpty() method 14 15 * - 2009-09-29 - bug correction in modelCollection::__get() when getting hasOne relation on foreign unique key 15 16 * - 2009-07-08 - new modelCollection::slice() method … … 330 331 return $chaining?$this:self::init($this->collectionType); 331 332 $temps = $this->getTemporaries(); 332 $this->remove($temps );333 $this->remove($temps->keys()); 333 334 return $chaining?$this:$temps; 334 335 } … … 630 631 } 631 632 633 /** check the collection is empty */ 634 function isEmpty(){ 635 return ($this->count()>0)?false:true; 636 } 632 637 /** return current model in collection @return abstractModel or null */ 633 638 function current(){ … … 1266 1271 if( $modelName instanceof abstractModel) 1267 1272 $modelName=$modelName->modelName; 1268 $collection = modelCollection::init($modelName); 1269 foreach(self::$instances as $instance){ 1270 if( $instance instanceof $modelName ) 1271 $collection[] = $model; 1272 } 1273 return $collection; 1273 return modelCollection::init($modelName,empty(self::$instances[strtolower($modelName)])?null:self::$instances[strtolower($modelName)]); 1274 1274 } 1275 1275 … … 1564 1564 $tmpModel = self::getModelInstance($relDef['modelName'],$localFieldVal); 1565 1565 } 1566 if( $tmpModel === false) # no related object was found in database create a new one1566 if(! $tmpModel instanceof abstractModel) # no related object was found in database create a new one 1567 1567 $tmpModel = self::getModelInstance($relDef['modelName']); 1568 1568 return $this->_oneModels[$relName] = $tmpModel;
