PageRenderTime 42ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/Model/VideoRelationship.php

https://github.com/Wargo/reddevil
PHP | 36 lines | 25 code | 11 blank | 0 comment | 0 complexity | 780ec382dcddc510ba5eb34b64d46330 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.1, GPL-3.0
  1. <?php
  2. class VideoRelationship extends AppModel {
  3. function getCategories($video_id) {
  4. $model = 'Category';
  5. $ids = $this->find('list', array(
  6. 'conditions' => compact('video_id', 'model'),
  7. 'fields' => array('foreign_id')
  8. ));
  9. return ClassRegistry::init('Category')->find('list', array(
  10. 'conditions' => array('id' => $ids),
  11. 'fields' => array('slug', 'name'),
  12. ));
  13. }
  14. function getActors($video_id) {
  15. $model = 'Actor';
  16. $ids = $this->find('list', array(
  17. 'conditions' => compact('video_id', 'model'),
  18. 'fields' => array('foreign_id')
  19. ));
  20. return ClassRegistry::init('Actor')->find('all', array(
  21. 'conditions' => array('id' => $ids),
  22. 'fields' => array('slug', 'name', 'gender'),
  23. ));
  24. }
  25. }