Subversion Repositories oidplus

Rev

Rev 1152 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1152 Rev 1156
Line 93... Line 93...
93
                $ret = odbc_num_rows($this->res);
93
                $ret = odbc_num_rows($this->res);
94
 
94
 
95
                // Workaround for drivers that do not support odbc_num_rows (e.g. Microsoft Access)
95
                // Workaround for drivers that do not support odbc_num_rows (e.g. Microsoft Access)
96
                if ($ret === -1) $ret = $this->num_rows_workaround();
96
                if ($ret === -1) $ret = $this->num_rows_workaround();
97
 
97
 
98
                if ($ret === -1) throw new OIDplusException(_L('The database driver has problems with "%1"','num_rows'));
-
 
99
 
-
 
100
                return $ret;
98
                return $ret;
101
        }
99
        }
102
 
100
 
103
        /**
101
        /**
104
         * @return array|null
102
         * @return array|null
105
         */
103
         */
106
        protected function do_fetch_array()/*: ?array*/ {
104
        protected function do_fetch_array()/*: ?array*/ {
107
                $ret = odbc_fetch_array($this->res);
105
                $ret = odbc_fetch_array($this->res);
108
                if ($ret === false) $ret = null;
106
                if ($ret === false) $ret = null;
109
                if (!is_null($ret)) {
-
 
110
                        // ODBC gives bit(1) as binary, MySQL as integer and PDO as string.
-
 
111
                        // We'll do it like MySQL does, even if ODBC is actually more correct.
-
 
112
                        foreach ($ret as &$value) {
-
 
113
                                if ($value === chr(0)) $value = 0;
-
 
114
                                if ($value === chr(1)) $value = 1;
-
 
115
                        }
-
 
116
                }
-
 
117
 
-
 
118
                // Oracle returns $ret['VALUE'] because unquoted column-names are always upper-case
-
 
119
                // We can't quote every single column throughout the whole program, so we use this workaround...
-
 
120
                if ($ret) {
-
 
121
                        $keys = array_keys($ret);
-
 
122
                        foreach($keys as $key) {
-
 
123
                                $ret[strtolower($key)]=$ret[$key];
-
 
124
                                $ret[strtoupper($key)]=$ret[$key];
-
 
125
                        }
-
 
126
                }
-
 
127
 
-
 
128
                return $ret;
107
                return $ret;
129
        }
108
        }
130
 
109
 
131
        /**
110
        /**
132
         * @return false|object|null
111
         * @return object|null
133
         */
112
         */
134
        protected function do_fetch_object()/*: ?object*/ {
113
        protected function do_fetch_object()/*: ?object*/ {
135
                $ret = odbc_fetch_object($this->res);
114
                $ret = odbc_fetch_object($this->res);
136
                if ($ret === false) $ret = null;
115
                if ($ret === false) $ret = null;
137
                if (!is_null($ret)) {
-
 
138
                        // ODBC gives bit(1) as binary, MySQL as integer and PDO as string.
-
 
139
                        // We'll do it like MySQL does, even if ODBC is actually more correct.
-
 
140
                        foreach ((array)$ret as &$value) {
-
 
141
                                if ($value === chr(0)) $value = 0;
-
 
142
                                if ($value === chr(1)) $value = 1;
-
 
143
                        }
-
 
144
                }
-
 
145
 
-
 
146
                // Oracle returns $ret['VALUE'] because unquoted column-names are always upper-case
-
 
147
                // We can't quote every single column throughout the whole program, so we use this workaround...
-
 
148
                if ($ret) {
-
 
149
                        foreach ((array)$ret as $name => $val) {
-
 
150
                                $ret->{strtoupper($name)} = $val;
-
 
151
                                $ret->{strtolower($name)} = $val;
-
 
152
                        }
-
 
153
                }
-
 
154
 
-
 
155
                return $ret;
116
                return $ret;
156
        }
117
        }
157
}
118
}