Subversion Repositories oidplus

Rev

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

Rev 1086 Rev 1116
Line 25... Line 25...
25
 
25
 
26
class OIDplusQueryResultMySQL extends OIDplusQueryResult {
26
class OIDplusQueryResultMySQL extends OIDplusQueryResult {
27
        protected $no_resultset;
27
        protected $no_resultset;
28
        protected $res;
28
        protected $res;
29
 
29
 
-
 
30
        /**
-
 
31
         * @param $res
-
 
32
         */
30
        public function __construct($res) {
33
        public function __construct($res) {
31
                $this->no_resultset = is_bool($res);
34
                $this->no_resultset = is_bool($res);
32
 
35
 
33
                if (!$this->no_resultset) {
36
                if (!$this->no_resultset) {
34
                        $this->res = $res;
37
                        $this->res = $res;
35
                }
38
                }
36
        }
39
        }
37
 
40
 
-
 
41
        /**
-
 
42
         *
-
 
43
         */
38
        public function __destruct() {
44
        public function __destruct() {
39
                if ($this->res) $this->res->close();
45
                if ($this->res) $this->res->close();
40
        }
46
        }
41
 
47
 
-
 
48
        /**
-
 
49
         * @return bool
-
 
50
         */
42
        public function containsResultSet(): bool {
51
        public function containsResultSet(): bool {
43
                return !$this->no_resultset;
52
                return !$this->no_resultset;
44
        }
53
        }
45
 
54
 
-
 
55
        /**
-
 
56
         * @return int
-
 
57
         * @throws OIDplusException
-
 
58
         */
46
        public function num_rows(): int {
59
        public function num_rows(): int {
47
                if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
60
                if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
48
                return $this->res->num_rows;
61
                return $this->res->num_rows;
49
        }
62
        }
50
 
63
 
-
 
64
        /**
-
 
65
         * @return array|null
-
 
66
         * @throws OIDplusException
-
 
67
         */
51
        public function fetch_array()/*: ?array*/ {
68
        public function fetch_array()/*: ?array*/ {
52
                if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
69
                if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
53
                return $this->res->fetch_array(MYSQLI_ASSOC);
70
                return $this->res->fetch_array(MYSQLI_ASSOC);
54
        }
71
        }
55
 
72
 
-
 
73
        /**
-
 
74
         * @return object|null
-
 
75
         * @throws OIDplusException
-
 
76
         */
56
        public function fetch_object()/*: ?object*/ {
77
        public function fetch_object()/*: ?object*/ {
57
                if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
78
                if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
58
                return $this->res->fetch_object("stdClass");
79
                return $this->res->fetch_object("stdClass");
59
        }
80
        }
60
}
81
}
61
82