Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // ...
- class Project extends Project_Generated implements CoughObjectStaticInterface {
- // ...
- /**
- * Override the default load method for category2project to pull category and
- * category type data in same query.
- *
- * @return void
- * @author Anthony Bush
- **/
- public function loadCategory2Project_Collection()
- {
- // Always create the collection
- $collection = new Category2project_Collection();
- $this->setCategory2project_Collection($collection);
- // But only populate it if we have key ID
- if (!$this->hasKeyId()) {
- return;
- }
- $db = Category2project::getDb();
- $tableName = Category2project::getTableName();
- $sql = '
- SELECT
- `' . $tableName . '`.*
- , ' . implode("\n\t, ", CoughObject::getFieldAliases('Category', 'Category_Object')) . '
- , ' . implode("\n\t, ", CoughObject::getFieldAliases('CategoryType', 'CategoryType_Object')) . '
- FROM
- `' . Category2project::getDbName() . '`.`' . $tableName . '`
- INNER JOIN `' . Category::getDbName() . '`.`' . Category::getTableName() . '` ON
- `' . Category::getTableName() . '`.category_id = `' . $tableName . '`.category_id
- INNER JOIN `' . CategoryType::getDbName() . '`.`' . CategoryType::getTableName() . '` ON
- `' . CategoryType::getTableName() . '`.category_type_id = `' . Category::getTableName() . '`.category_type_id
- WHERE
- `' . $tableName . '`.`project_id` = ' . $db->quote($this->getProjectId()) . '
- ';
- // Construct and populate the collection
- $collection->loadBySql($sql);
- foreach ($collection as $element) {
- $element->setProject_Object($this);
- }
- }
- // ...
- }
Add Comment
Please, Sign In to add comment