Rev 786 | Rev 1086 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 786 | Rev 1050 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | * See the License for the specific language governing permissions and |
16 | * See the License for the specific language governing permissions and |
17 | * limitations under the License. |
17 | * limitations under the License. |
18 | */ |
18 | */ |
19 | 19 | ||
20 | if (!defined('INSIDE_OIDPLUS')) die(); |
20 | namespace ViaThinkSoft\OIDplus; |
21 | 21 | ||
22 | class OIDplusQueryResultPDO extends OIDplusQueryResult { |
22 | class OIDplusQueryResultPDO extends OIDplusQueryResult { |
23 | protected $no_resultset; |
23 | protected $no_resultset; |
24 | protected $res; |
24 | protected $res; |
25 | 25 | ||
Line 66... | Line 66... | ||
66 | public function fetch_array()/*: ?array*/ { |
66 | public function fetch_array()/*: ?array*/ { |
67 | if (!is_null($this->prefetchedArray)) { |
67 | if (!is_null($this->prefetchedArray)) { |
68 | $ret = array_shift($this->prefetchedArray); |
68 | $ret = array_shift($this->prefetchedArray); |
69 | } else { |
69 | } else { |
70 | if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)')); |
70 | if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)')); |
71 | $ret = $this->res->fetch(PDO::FETCH_ASSOC); |
71 | $ret = $this->res->fetch(\PDO::FETCH_ASSOC); |
72 | if ($ret === false) $ret = null; |
72 | if ($ret === false) $ret = null; |
73 | } |
73 | } |
74 | if ($ret) $this->countAlreadyFetched++; |
74 | if ($ret) $this->countAlreadyFetched++; |
75 | 75 | ||
76 | // Oracle returns $ret['VALUE'] because unquoted column-names are always upper-case |
76 | // Oracle returns $ret['VALUE'] because unquoted column-names are always upper-case |
Line 85... | Line 85... | ||
85 | 85 | ||
86 | return $ret; |
86 | return $ret; |
87 | } |
87 | } |
88 | 88 | ||
89 | private static function array_to_stdobj($ary) { |
89 | private static function array_to_stdobj($ary) { |
90 | $obj = new stdClass; |
90 | $obj = new \stdClass; |
91 | foreach ($ary as $name => $val) { |
91 | foreach ($ary as $name => $val) { |
92 | $obj->$name = $val; |
92 | $obj->$name = $val; |
93 | } |
93 | } |
94 | return $obj; |
94 | return $obj; |
95 | } |
95 | } |
Line 98... | Line 98... | ||
98 | if (!is_null($this->prefetchedArray)) { |
98 | if (!is_null($this->prefetchedArray)) { |
99 | $ary = array_shift($this->prefetchedArray); |
99 | $ary = array_shift($this->prefetchedArray); |
100 | $ret = is_null($ary) ? null : self::array_to_stdobj($ary); |
100 | $ret = is_null($ary) ? null : self::array_to_stdobj($ary); |
101 | } else { |
101 | } else { |
102 | if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)')); |
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 | $ret = $this->res->fetch(PDO::FETCH_OBJ); |
103 | $ret = $this->res->fetch(\PDO::FETCH_OBJ); |
104 | if ($ret === false) $ret = null; |
104 | if ($ret === false) $ret = null; |
105 | } |
105 | } |
106 | if ($ret) $this->countAlreadyFetched++; |
106 | if ($ret) $this->countAlreadyFetched++; |
107 | 107 | ||
108 | // Oracle returns $ret['VALUE'] because unquoted column-names are always upper-case |
108 | // Oracle returns $ret['VALUE'] because unquoted column-names are always upper-case |