diff --git a/application/models/rows/Asset.php b/application/models/rows/Asset.php new file mode 100644 index 0000000000000000000000000000000000000000..18d3af9ce4021906bd45bad354b584a175e9d6fa --- /dev/null +++ b/application/models/rows/Asset.php @@ -0,0 +1,8 @@ +<?php + +class Asset extends Nmc_Db_Table_Row +{ + static public $tableClass = 'Assets'; +} + +?> \ No newline at end of file diff --git a/application/models/rows/CourseGeneration.php b/application/models/rows/CourseGeneration.php index 0e4eb488b4bc033cda03caf75ef3acc35110e88b..1f2361e2e2834fce7a0afe3e70347f01fe1fee55 100644 --- a/application/models/rows/CourseGeneration.php +++ b/application/models/rows/CourseGeneration.php @@ -2,17 +2,14 @@ class CourseGeneration extends Nmc_Db_Table_Row { - /* - public $request; - public $gradTieIn; - public $integratedStudies; - */ protected $_homeCrosslisting; public function __construct($config = array()) { parent::__construct($config); + $this->_registerRelation( + new Nmc_Db_Table_Relation_Extend(Assets::getInstance(), $this, 'assetId')); $this->_registerRelation( new Nmc_Db_Table_Relation_HasOne(CourseDetails::getInstance(), $this, 'generation')); $this->_registerRelation( @@ -89,7 +86,7 @@ class CourseGeneration extends Nmc_Db_Table_Row } $saveCourse = $this->course; - $saveCreated = $this->created; + $saveCreationTime = $this->creationTime; if($this->request instanceof Request) { $saveRequest = $this->request->toArray(); } @@ -101,8 +98,8 @@ class CourseGeneration extends Nmc_Db_Table_Row $course->save(); $this->course = $course->id; } - if(!$this->created) { - $this->created = time(); + if(!$this->creationTime) { + $this->creationTime = time(); } if($this->request instanceof Request) { @@ -123,7 +120,7 @@ class CourseGeneration extends Nmc_Db_Table_Row } $this->course = $saveCourse; - $this->created = $saveCreated; + $this->creationTime = $saveCreationTime; if($this->request instanceof Request) { $this->_data['request'] = $saveRequestId; $this->request->setFromArray($saveRequest); diff --git a/application/models/rows/Request.php b/application/models/rows/Request.php index d0f0349a715171a078c19754d44b9956cfa05230..91f16e463a168630f237ca7ecc8639dffc6992eb 100644 --- a/application/models/rows/Request.php +++ b/application/models/rows/Request.php @@ -19,11 +19,19 @@ class Request extends Nmc_Db_Table_Row { $returnValue = null; - $where = $this->_db->quoteInto('request = ?', $this->id); - $order = 'created'; - $generations = CourseGenerations::getInstance()->fetchAll($where, $order); - if($generations->count() > 0) { - $returnValue = $generations[0]; + $select = $this->_db->select(); + $select->from(CourseGenerations::getInstance()->getTableName(), + CourseGenerations::getInstance()->getPrimaryKeyName()); + $select->join(Assets::getInstance()->getTableName(), + CourseGenerations::getInstance()->getTableName() + . '.asset_id = ' + . Assets::getInstance()->getTableName() . '.' + . Assets::getInstance()->getPrimaryKeyName()); + $select->where($this->_db->quoteInto('request = ?', $this->id)); + $select->order('creation_time'); + $generations = $this->_db->fetchCol($select); + if(count($generations) > 0) { + $returnValue = CourseGenerations::getInstance()->find($generations[0]); } return $returnValue; diff --git a/application/models/tables/Assets.php b/application/models/tables/Assets.php new file mode 100644 index 0000000000000000000000000000000000000000..5fe66a7f93add33c7d6583a4e0d20cd2f71d6c68 --- /dev/null +++ b/application/models/tables/Assets.php @@ -0,0 +1,30 @@ +<?php + +class Assets extends Nmc_Db_Table +{ + protected $_rowClass = 'Asset'; + + /** + * The one true instance + * + * @var Assets + */ + protected static $_instance = null; + + /** + * Returns the one true instance + * + * @return Assets + */ + public static function getInstance($config = array()) + { + if(!self::$_instance) { + self::$_instance = new Assets($config); + } + return self::$_instance; + } + + +} + +?> \ No newline at end of file