PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | libraries/adapter/database/database.php +50 -4 1.6.5 → 1.8.16 View file →
@@ -203,10 +203,10 @@
203 203 // save the query with the real db prefix
204 204 $this->q = $this->replacePrefix($q);
205 205
206 206 // register offset and limit (always override previous values)
207 - $this->offset = abs($offset);
208 - $this->limit = abs($limit);
207 + $this->offset = abs((int) $offset);
208 + $this->limit = abs((int) $limit);
209 209
210 210 return $this;
211 211 }
212 212
@@ -253,8 +253,15 @@
253 253 if (preg_match("/^(SELECT|SHOW)/i", $sql))
254 254 {
255 255 // result should contain an array
256 256 $this->result = $this->db->get_results($sql);
257 +
258 + /**
259 + * Flush result after executing the query to free disk space.
260 + *
261 + * @since 10.1.73
262 + */
263 + $this->db->flush();
257 264 }
258 265 // otherwise we can launch a generic query
259 266 else
260 267 {
@@ -323,9 +330,17 @@
323 330 }
324 331
325 332 if (is_array($this->result))
326 333 {
327 - return $this->result;
334 + /**
335 + * Copy result on a local variable and flush the cached value.
336 + *
337 + * @since 10.1.73
338 + */
339 + $result = $this->result;
340 + $this->result = null;
341 +
342 + return $result;
328 343 }
329 344
330 345 return array();
331 346 }
@@ -668,8 +683,20 @@
668 683 return $affected !== false;
669 684 }
670 685
671 686 /**
687 + * Returns the error faced (if any) during the last query execution.
688 + *
689 + * @return string The error message.
690 + *
691 + * @since 10.1.58
692 + */
693 + public function getLastError()
694 + {
695 + return $this->db->last_error;
696 + }
697 +
698 + /**
672 699 * Returns a PHP date() function compliant date format for the database driver.
673 700 *
674 701 * @return string The format string.
675 702 */
@@ -725,9 +752,14 @@
725 752 * @since 10.1.19
726 753 */
727 754 public function getTableColumns($table, $typeOnly = true)
728 755 {
729 - $q = "SHOW FULL COLUMNS FROM " . $this->qn($table);
756 + /**
757 + * Do not escape the table name to support SQLite too.
758 + *
759 + * @since 10.1.53
760 + */
761 + $q = "SHOW FULL COLUMNS FROM " . $table;
730 762
731 763 // set the query to get the table fields statement
732 764 $this->setQuery($q);
733 765 $this->execute();
@@ -733,8 +765,10 @@
733 765 $this->execute();
734 766
735 767 $fields = $this->loadObjectList();
736 768
769 + $result = [];
770 +
737 771 // if we only want the type as the value add just that to the list.
738 772 if ($typeOnly)
739 773 {
740 774 foreach ($fields as $field)
@@ -746,8 +780,20 @@
746 780 else
747 781 {
748 782 foreach ($fields as $field)
749 783 {
784 + /**
785 + * With SQLite the Extra column might not be included.
786 + * Simulate the same result by checking whether the column
787 + * is equal to `id` and force the "auto_increment" rule.
788 + *
789 + * @since 10.1.53
790 + */
791 + if (!isset($field->Extra))
792 + {
793 + $field->Extra = $field->Field === 'id' ? 'auto_increment' : '';
794 + }
795 +
750 796 $result[$field->Field] = $field;
751 797 }
752 798 }
753 799