Rev 1130 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1130 | Rev 1152 | ||
---|---|---|---|
Line 85... | Line 85... | ||
85 | return !$this->no_resultset; |
85 | return !$this->no_resultset; |
86 | } |
86 | } |
87 | 87 | ||
88 | /** |
88 | /** |
89 | * @return int |
89 | * @return int |
90 | * @throws OIDplusException |
- | |
91 | */ |
90 | */ |
92 | public function num_rows(): int { |
91 | protected function do_num_rows(): int { |
93 | if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)')); |
- | |
94 | return count($this->all_results); |
92 | return count($this->all_results); |
95 | } |
93 | } |
96 | 94 | ||
97 | /** |
95 | /** |
98 | * @return array|mixed|null |
96 | * @return array|mixed|null |
99 | * @throws OIDplusException |
- | |
100 | */ |
97 | */ |
101 | public function fetch_array()/*: ?array*/ { |
98 | protected function do_fetch_array()/*: ?array*/ { |
102 | if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)')); |
- | |
103 | - | ||
104 | //$ret = $this->res->fetchArray(SQLITE3_ASSOC); |
99 | //$ret = $this->res->fetchArray(SQLITE3_ASSOC); |
105 | $cursor = $this->cursor; |
100 | $cursor = $this->cursor; |
106 | if (!isset($this->all_results[$cursor])) return null; |
101 | if (!isset($this->all_results[$cursor])) return null; |
107 | $ret = $this->all_results[$cursor]; |
102 | $ret = $this->all_results[$cursor]; |
108 | $cursor++; |
103 | $cursor++; |
Line 110... | Line 105... | ||
110 | 105 | ||
111 | if ($ret === false) $ret = null; |
106 | if ($ret === false) $ret = null; |
112 | return $ret; |
107 | return $ret; |
113 | } |
108 | } |
114 | 109 | ||
115 | /** |
- | |
116 | * @return \stdClass|null |
- | |
117 | * @throws OIDplusException |
- | |
118 | */ |
- | |
119 | public function fetch_object()/*: ?object*/ { |
- | |
120 | if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)')); |
- | |
121 | - | ||
122 | $ary = $this->fetch_array(); |
- | |
123 | if (!$ary) return null; |
- | |
124 | - | ||
125 | $obj = new \stdClass; |
- | |
126 | foreach ($ary as $name => $val) { |
- | |
127 | $obj->$name = $val; |
- | |
128 | } |
- | |
129 | return $obj; |
- | |
130 | } |
- | |
131 | } |
110 | } |