Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. public function fetch($id)
  2. {
  3. $table = new TableGateway('web_project', $this->adapter);
  4.  
  5. $rowset = $table->select(function($select) use ($id) {
  6. $select->columns(array('projectname' => 'projectname', 'projectdescription' => 'description', 'projectcreationdate' => 'creationdate'));
  7. $select->join(
  8. array('t1' => 'web_prjcontext'),
  9. 't1.fk_web_project = web_project.id',
  10. array('contextname' => 'name', 'contextdescription' => 'description'),
  11. Select::JOIN_LEFT
  12. );
  13. $select->join(
  14. array('t2' => 'web_prjright'),
  15. 't2.fk_web_prjcontext = t1.id',
  16. array('rightname' => 'name', 'rightmatrix' => 'matrix', 'rightdescription' => 'description'),
  17. Select::JOIN_LEFT
  18. );
  19. $select->where(array('projectname' => $id));
  20. $select->order(array('t1.name asc'));
  21. $select->order(array('t2.name asc'));
  22. });
  23.  
  24. $dataEntity = array();
  25. $dataEmbedded = array();
  26.  
  27. foreach ($rowset as $row) {
  28. if (!isset($dataEntity['name'])) {
  29. $dataEntity['name'] = $this->cpcDbToClient->convert($row->projectname);
  30. $dataEntity['description'] = $this->cpcDbToClient->convert(stream_get_contents($row->projectdescription));
  31. $dataEntity['creationDate'] = $row->projectcreationdate;
  32. }
  33.  
  34. if ($row->contextname) {
  35. $contextName = $this->cpcDbToClient->convert($row->contextname);
  36.  
  37. if (!$dataEmbedded[$contextName]) {
  38. $dataEmbedded[$contextName] = new RightscontextsEntity(
  39. array(
  40. 'name' => $contextName,
  41. 'description' => $this->cpcDbToClient->convert($row->contextdescription),
  42. )
  43. );
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement