- if (is_callable($row)) {
- while (($data = $result->fetchRow(\pq\Result::FETCH_ASSOC))) {
- $this->rows[] = $row($data);
- }
- } else {
- while (($data = $result->fetchRow(\pq\Result::FETCH_ASSOC))) {
- $this->rows[] = new $row($this->table, $data);
+ if ($result) {
+ $row = $this->getRowPrototype();
+
+ if (is_callable($row)) {
+ while (($data = $result->fetchRow(\pq\Result::FETCH_ASSOC))) {
+ $this->rows[] = $row($data);
+ }
+ } elseif ($row) {
+ while (($data = $result->fetchRow(\pq\Result::FETCH_ASSOC))) {
+ $this->rows[] = new $row($this->table, $data);
+ }
+ } else {
+ $this->rows = $result->fetchAll(\pq\Result::FETCH_OBJECT);