37 require_once realpath(dirname(__FILE__).
"/query.inc");
60 $this->item =
new $this->
query->class;
66 trace(
"Row Count: {$this->query->rowCount}", 4);
67 return $this->
query->rowCount;
72 if ($this->position == 0)
return;
79 $this->result = $this->
query->_runQuery();
80 $this->
current = $this->result->fetch();
82 catch(PDOException $e)
84 throw new FakoliException($e->getMessage());
90 $this->item->populate($this->
current);
96 return ($this->
current !=
null);
101 $this->
current = $this->result->fetch();
112 if (!is_numeric($offset))
return false;
113 return ($offset >= 0 && $offset < $this->
query->rowCount);
118 if ($offset == $this->position)
return $this->item;
120 if ($offset < $this->position)
138 throw new FakoliException(
"Attempt to write to iterated data query");
143 throw new FakoliException(
"Attempt to write to iterated data query");
175 $order_by_idx = strpos(strtoupper($this->
constraints),
"ORDER BY");
178 if ($order_by_idx !==
false)
180 $orderBy = substr($this->
constraints, $order_by_idx);
186 $this->
constraints .=
" ".$prototype->getIdentityConstraint();
188 $query =
"SELECT ".$prototype->getFieldList().
" FROM {$prototype->table} {$this->tableAlias} {$this->constraints} $orderBy";
196 $result = $db->prepare($query);
197 $result->execute($this->
params);
198 $this->rowCount = $result->rowCount();
201 catch(PDOException $e)
203 throw new FakoliException($e->getMessage());
243 if (func_num_args() > 1)
245 $query->constraints(func_get_arg(1));
247 if (func_num_args() > 2)
249 $query->filter(func_get_arg(3));
253 return $query->execute();
constraints($constraints)
Sets the constraint clause for the Query.
params($params)
Sets the bound parameters array.
static getConnection()
Retrieves a reference to the global database connection.
DataItemIterator is a memory-efficient iterator class that can be used when rendering large data sets...
offsetSet($offset, $value)
IteratedQuery provides a memory-efficient way to query and return large data sets.
__construct($class, $constraints="")
static create($class, $constraints="")
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
iteratedQuery($class)
iteratedQuery() provides a memory-efficient way to query and return large data sets.
query($class)
Performs a query against the database, returning an array of DataItem objects of the specified class.