MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
cursor.class
Ir para a documentação deste ficheiro.
1<?php
2
3class Cursor
4{
5 private $position;
6
7 private $rows;
8 private $classMap;
9 private $proxy;
10 private $size;
11 private $manager;
12 private $baseObject;
13
14 public function __construct($query, Classmap $classMap, $proxy = FALSE, PersistentManager $manager)
15 {
16 $this->position = 0;
17 $this->query = $query;
18 $this->query->moveFirst();
19 $this->rows = $query->result;
20 $this->size = (is_array($result)) ? count($result) : 0;
21 $this->classMap = $classMap;
22 $this->baseObject = $this->classMap->getObject();
23 $this->proxy = $proxy;
24 $this->manager = $manager;
25 }
26
27 public function getRow()
28 {
29 $row = NULL;
30 if (!$this->query->eof())
31 {
32 $row = $this->query->getRowValues();
33 $this->query->moveNext();
34 }
35 return $row;
36 }
37
38 public function retrieveObject($object)
39 {
40 if ($this->proxy)
41 $this->classMap->retrieveProxyObject($object, $this->query);
42 else
43 $this->classMap->retrieveObject($object, $this->query);
44
45 // Associations
46 if ($this->classMap->getAssociationSize() > 0)
47 {
48 $db = $this->manager->getConnection($this->classMap->getDatabase());
49 $this->manager->_retrieveAssociations($object, $this->classMap, $db);
50 }
51 }
52
53 public function getObject()
54 {
55 $object = NULL;
56 if (!$this->query->eof())
57 {
58 if ($this->baseObject == NULL)
59 {
60 $object = $this->getRow();
61 }
62 else
63 {
64 $object = clone $this->baseObject;
65 $this->retrieveObject($object);
66 }
67 $this->query->moveNext();
68 }
69 return $object;
70 }
71
72 public function getObjects()
73 {
74 $array = array();
75 $this->query->moveFirst();
76 while (!$this->query->eof())
77 {
78 $object = clone $this->baseObject;
79 $this->retrieveObject($object);
80 $array[] = $object;
81 $this->query->moveNext();
82 }
83 return $array;
84 }
85
86 public function getSize()
87 {
88 return $this->size;
89 }
90}
91?>
getObjects()
Definição cursor.class:72
__construct($query, Classmap $classMap, $proxy=FALSE, PersistentManager $manager)
Definição cursor.class:14
getRow()
Definição cursor.class:27
getSize()
Definição cursor.class:86
getObject()
Definição cursor.class:53
retrieveObject($object)
Definição cursor.class:38