Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ec1d525

Browse files
fix: Fixed bug on db::empty when dbObject is given
1 parent cb4377e commit ec1d525

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎db.class.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* 2021年03月12日 -> Added a lot of comments
88
* 2021年06月05日 -> Added transformWith private method for insert and update methods using the $additional array. Added formatMonney public method to work with monetary values. Changed getPageNow to getCurrentPage. Added search method.
99
* 2021年08月17日 -> Made a few improvements within base core functions
10+
* 2021年11月16日 -> Fixed Fetch method when same SQL is called more than once
1011
*/
1112

1213
class db
@@ -137,9 +138,9 @@ private static function encapsulate($mixed)
137138
$instance = new dbObject(self::getInstance()->query($mixed), array("key" => $key));
138139
self::$object[$key] = $instance;
139140
}
140-
if (self::$object[$key]->extra["rows"] === self::$object[$key]->extra["totalEntries"]) {
141+
if (self::$object[$key]->extra["rows"] + 1 == self::$object[$key]->extra["totalEntries"] && self::$object[$key]->extra["totalEntries"] !== 0) {
141142
unset(self::$object[$key]);
142-
return false;
143+
return self::encapsulate($mixed);
143144
}
144145
return self::$object[$key];
145146
}
@@ -162,7 +163,8 @@ public static function fetch($mixed, $simple = false)
162163
}
163164
}
164165
$mixed = self::encapsulate($mixed);
165-
return ($mixed ? $mixed->getData() : $mixed);
166+
return $mixed->getData();
167+
//return ($mixed ? $mixed->getData() : $mixed);
166168
}
167169
if ($mixed instanceof dbObject) {
168170
return $mixed->getData();
@@ -205,7 +207,7 @@ public static function empty($query)
205207
return (self::query($query)->getInstance()->rowCount() == 0);
206208
}
207209
if ($query instanceof dbObject) {
208-
return ($query->getInstance()->rowCount() == 1);
210+
return ($query->getInstance()->rowCount() == 0);
209211
}
210212
if (is_bool($query)) {
211213
return !$query;
@@ -578,6 +580,8 @@ public static function insert($data, $table, $additional = array())
578580
unset($stmnt, $instance);
579581
return true;
580582
} else {
583+
echo "\nPDO::errorInfo():\n";
584+
print_r($stmnt->errorInfo());
581585
return false;
582586
}
583587
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /