PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/Model/PhotoRelationship.php

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