sql = $sql; } else { // SQL command $this->sql = '(' . $sql . ') AS [source]'; } $this->connection = $connection === NULL ? dibi::getConnection() : $connection; } /** * @param int offset * @param int limit * @param array columns * @return ArrayIterator */ public function getIterator($offset = NULL, $limit = NULL, $cols = NULL) { return $this->connection->query(' SELECT * FROM', $this->sql, ' %ofs %lmt', $offset, $limit ); } /** * @return int */ public function count() { if ($this->count === NULL) { $this->count = $this->connection->query(' SELECT COUNT(*) FROM', $this->sql )->fetchSingle(); } return $this->count; } }