| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/core/src/lmbCollectionDecorator.class.php'); 10 lmb_require('limb/core/src/lmbClassPath.class.php'); 11 12 /** 13 * class lmbARRecordSetDecorator. 14 * 15 * @package active_record 16 * @version $Id: lmbARRecordSetDecorator.class.php 5997 2007-06-18 12:27:21Z pachanga $ 17 */ 18 class lmbARRecordSetDecorator extends lmbCollectionDecorator 19 { 20 protected $class_path; 21 protected $conn; 22 23 function __construct($record_set, $class_path = '', $conn = null) 24 { 25 $this->class_path = $class_path; 26 $this->conn = $conn; 27 28 parent :: __construct($record_set); 29 } 30 31 function setClassPath($class_path) 32 { 33 $this->class_path = $class_path; 34 } 35 36 function current() 37 { 38 if(!$this->class_path) 39 throw new lmbException('ActiveRecord class path is not defined'); 40 41 if(!$record = parent :: current()) 42 return null; 43 44 return $this->_createObjectFromRecord($record); 45 } 46 47 protected function _createObjectFromRecord($record) 48 { 49 $object = $this->_createObject($record); 50 $object->loadFromRecord($record); 51 return $object; 52 } 53 54 protected function _createObject($record) 55 { 56 if($path = $record->get(lmbActiveRecord :: getInheritanceField())) 57 { 58 $class = end(lmbActiveRecord :: decodeInheritancePath($path)); 59 if(!class_exists($class)) 60 throw new lmbException("Class '$class' not found"); 61 return new $class(null, $this->conn); 62 } 63 else 64 return lmbClassPath :: create($this->class_path, array(null, $this->conn)); 65 } 66 67 function at($pos) 68 { 69 if(!$record = parent :: at($pos)) 70 return null; 71 72 return $this->_createObjectFromRecord($record); 73 } 74 } 75 76 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Nov 22 03:48:54 2008 | Cross-referenced by PHPXref 0.7 |