PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.3
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.3
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/SQLite.php +306 -307 3.1.23.0.3 View file →
@@ -1,307 +1,306 @@
1 -<?php
2 -
3 -/**
4 - * PHPExcel_CachedObjectStorage_SQLite
5 - *
6 - * Copyright (c) 2006 - 2015 PHPExcel
7 - *
8 - * This library is free software; you can redistribute it and/or
9 - * modify it under the terms of the GNU Lesser General Public
10 - * License as published by the Free Software Foundation; either
11 - * version 2.1 of the License, or (at your option) any later version.
12 - *
13 - * This library is distributed in the hope that it will be useful,
14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 - * Lesser General Public License for more details.
17 - *
18 - * You should have received a copy of the GNU Lesser General Public
19 - * License along with this library; if not, write to the Free Software
20 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 - *
22 - * @category PHPExcel
23 - * @package PHPExcel_CachedObjectStorage
24 - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
25 - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
26 - * @version ##VERSION##, ##DATE##
27 - */
28 -class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
29 -{
30 - /**
31 - * Database table name
32 - *
33 - * @var string
34 - */
35 - private $TableName = null;
36 -
37 - /**
38 - * Database handle
39 - *
40 - * @var resource
41 - */
42 - private $DBHandle = null;
43 -
44 - /**
45 - * Store cell data in cache for the current cell object if it's "dirty",
46 - * and the 'nullify' the current cell object
47 - *
48 - * @return void
49 - * @throws PHPExcel_Exception
50 - */
51 - protected function storeData()
52 - {
53 - if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
54 - $this->currentObject->detach();
55 -
56 - if (!$this->DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES('".$this->currentObjectID."','".sqlite_escape_string(serialize($this->currentObject))."')")) {
57 - throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
58 - }
59 - $this->currentCellIsDirty = false;
60 - }
61 - $this->currentObjectID = $this->currentObject = null;
62 - }
63 -
64 - /**
65 - * Add or Update a cell in cache identified by coordinate address
66 - *
67 - * @param string $pCoord Coordinate address of the cell to update
68 - * @param PHPExcel_Cell $cell Cell to update
69 - * @return PHPExcel_Cell
70 - * @throws PHPExcel_Exception
71 - */
72 - public function addCacheData($pCoord, PHPExcel_Cell $cell)
73 - {
74 - if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
75 - $this->storeData();
76 - }
77 -
78 - $this->currentObjectID = $pCoord;
79 - $this->currentObject = $cell;
80 - $this->currentCellIsDirty = true;
81 -
82 - return $cell;
83 - }
84 -
85 - /**
86 - * Get cell at a specific coordinate
87 - *
88 - * @param string $pCoord Coordinate of the cell
89 - * @throws PHPExcel_Exception
90 - * @return PHPExcel_Cell Cell that was found, or null if not found
91 - */
92 - public function getCacheData($pCoord)
93 - {
94 - if ($pCoord === $this->currentObjectID) {
95 - return $this->currentObject;
96 - }
97 - $this->storeData();
98 -
99 - $query = "SELECT value FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
100 - $cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
101 - if ($cellResultSet === false) {
102 - throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
103 - } elseif ($cellResultSet->numRows() == 0) {
104 - // Return null if requested entry doesn't exist in cache
105 - return null;
106 - }
107 -
108 - // Set current entry to the requested entry
109 - $this->currentObjectID = $pCoord;
110 -
111 - $cellResult = $cellResultSet->fetchSingle();
112 - $this->currentObject = unserialize($cellResult);
113 - // Re-attach this as the cell's parent
114 - $this->currentObject->attach($this);
115 -
116 - // Return requested entry
117 - return $this->currentObject;
118 - }
119 -
120 - /**
121 - * Is a value set for an indexed cell?
122 - *
123 - * @param string $pCoord Coordinate address of the cell to check
124 - * @return boolean
125 - */
126 - public function isDataSet($pCoord)
127 - {
128 - if ($pCoord === $this->currentObjectID) {
129 - return true;
130 - }
131 -
132 - // Check if the requested entry exists in the cache
133 - $query = "SELECT id FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
134 - $cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
135 - if ($cellResultSet === false) {
136 - throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
137 - } elseif ($cellResultSet->numRows() == 0) {
138 - // Return null if requested entry doesn't exist in cache
139 - return false;
140 - }
141 - return true;
142 - }
143 -
144 - /**
145 - * Delete a cell in cache identified by coordinate address
146 - *
147 - * @param string $pCoord Coordinate address of the cell to delete
148 - * @throws PHPExcel_Exception
149 - */
150 - public function deleteCacheData($pCoord)
151 - {
152 - if ($pCoord === $this->currentObjectID) {
153 - $this->currentObject->detach();
154 - $this->currentObjectID = $this->currentObject = null;
155 - }
156 -
157 - // Check if the requested entry exists in the cache
158 - $query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
159 - if (!$this->DBHandle->queryExec($query)) {
160 - throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
161 - }
162 -
163 - $this->currentCellIsDirty = false;
164 - }
165 -
166 - /**
167 - * Move a cell object from one address to another
168 - *
169 - * @param string $fromAddress Current address of the cell to move
170 - * @param string $toAddress Destination address of the cell to move
171 - * @return boolean
172 - */
173 - public function moveCell($fromAddress, $toAddress)
174 - {
175 - if ($fromAddress === $this->currentObjectID) {
176 - $this->currentObjectID = $toAddress;
177 - }
178 -
179 - $query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$toAddress."'";
180 - $result = $this->DBHandle->exec($query);
181 - if ($result === false) {
182 - throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
183 - }
184 -
185 - $query = "UPDATE kvp_".$this->TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
186 - $result = $this->DBHandle->exec($query);
187 - if ($result === false) {
188 - throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
189 - }
190 -
191 - return true;
192 - }
193 -
194 - /**
195 - * Get a list of all cell addresses currently held in cache
196 - *
197 - * @return string[]
198 - */
199 - public function getCellList()
200 - {
201 - if ($this->currentObjectID !== null) {
202 - $this->storeData();
203 - }
204 -
205 - $query = "SELECT id FROM kvp_".$this->TableName;
206 - $cellIdsResult = $this->DBHandle->unbufferedQuery($query, SQLITE_ASSOC);
207 - if ($cellIdsResult === false) {
208 - throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
209 - }
210 -
211 - $cellKeys = array();
212 - foreach ($cellIdsResult as $row) {
213 - $cellKeys[] = $row['id'];
214 - }
215 -
216 - return $cellKeys;
217 - }
218 -
219 - /**
220 - * Clone the cell collection
221 - *
222 - * @param PHPExcel_Worksheet $parent The new worksheet
223 - * @return void
224 - */
225 - public function copyCellCollection(PHPExcel_Worksheet $parent)
226 - {
227 - $this->currentCellIsDirty;
228 - $this->storeData();
229 -
230 - // Get a new id for the new table name
231 - $tableName = str_replace('.', '_', $this->getUniqueID());
232 - if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
233 - AS SELECT * FROM kvp_'.$this->TableName)
234 - ) {
235 - throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
236 - }
237 -
238 - // Copy the existing cell cache file
239 - $this->TableName = $tableName;
240 - }
241 -
242 - /**
243 - * Clear the cell collection and disconnect from our parent
244 - *
245 - * @return void
246 - */
247 - public function unsetWorksheetCells()
248 - {
249 - if (!is_null($this->currentObject)) {
250 - $this->currentObject->detach();
251 - $this->currentObject = $this->currentObjectID = null;
252 - }
253 - // detach ourself from the worksheet, so that it can then delete this object successfully
254 - $this->parent = null;
255 -
256 - // Close down the temporary cache file
257 - $this->__destruct();
258 - }
259 -
260 - /**
261 - * Initialise this new cell collection
262 - *
263 - * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
264 - */
265 - public function __construct(PHPExcel_Worksheet $parent)
266 - {
267 - parent::__construct($parent);
268 - if (is_null($this->DBHandle)) {
269 - $this->TableName = str_replace('.', '_', $this->getUniqueID());
270 - $_DBName = ':memory:';
271 -
272 - $this->DBHandle = new SQLiteDatabase($_DBName);
273 - if ($this->DBHandle === false) {
274 - throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
275 - }
276 - if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
277 - throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
278 - }
279 - }
280 - }
281 -
282 - /**
283 - * Destroy this cell collection
284 - */
285 - public function __destruct()
286 - {
287 - if (!is_null($this->DBHandle)) {
288 - $this->DBHandle->queryExec('DROP TABLE kvp_'.$this->TableName);
289 - }
290 - $this->DBHandle = null;
291 - }
292 -
293 - /**
294 - * Identify whether the caching method is currently available
295 - * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
296 - *
297 - * @return boolean
298 - */
299 - public static function cacheMethodIsAvailable()
300 - {
301 - if (!function_exists('sqlite_open')) {
302 - return false;
303 - }
304 -
305 - return true;
306 - }
307 -}
1 +<?php
2 +/**
3 + * PHPExcel
4 + *
5 + * Copyright (c) 2006 - 2014 PHPExcel
6 + *
7 + * This library is free software; you can redistribute it and/or
8 + * modify it under the terms of the GNU Lesser General Public
9 + * License as published by the Free Software Foundation; either
10 + * version 2.1 of the License, or (at your option) any later version.
11 + *
12 + * This library is distributed in the hope that it will be useful,
13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 + * Lesser General Public License for more details.
16 + *
17 + * You should have received a copy of the GNU Lesser General Public
18 + * License along with this library; if not, write to the Free Software
19 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 + *
21 + * @category PHPExcel
22 + * @package PHPExcel_CachedObjectStorage
23 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24 + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 + * @version ##VERSION##, ##DATE##
26 + */
27 +
28 +
29 +/**
30 + * PHPExcel_CachedObjectStorage_SQLite
31 + *
32 + * @category PHPExcel
33 + * @package PHPExcel_CachedObjectStorage
34 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35 + */
36 +class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
37 +
38 + /**
39 + * Database table name
40 + *
41 + * @var string
42 + */
43 + private $_TableName = null;
44 +
45 + /**
46 + * Database handle
47 + *
48 + * @var resource
49 + */
50 + private $_DBHandle = null;
51 +
52 + /**
53 + * Store cell data in cache for the current cell object if it's "dirty",
54 + * and the 'nullify' the current cell object
55 + *
56 + * @return void
57 + * @throws PHPExcel_Exception
58 + */
59 + protected function _storeData() {
60 + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
61 + $this->_currentObject->detach();
62 +
63 + if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')"))
64 + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
65 + $this->_currentCellIsDirty = false;
66 + }
67 + $this->_currentObjectID = $this->_currentObject = null;
68 + } // function _storeData()
69 +
70 +
71 + /**
72 + * Add or Update a cell in cache identified by coordinate address
73 + *
74 + * @param string $pCoord Coordinate address of the cell to update
75 + * @param PHPExcel_Cell $cell Cell to update
76 + * @return PHPExcel_Cell
77 + * @throws PHPExcel_Exception
78 + */
79 + public function addCacheData($pCoord, PHPExcel_Cell $cell) {
80 + if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
81 + $this->_storeData();
82 + }
83 +
84 + $this->_currentObjectID = $pCoord;
85 + $this->_currentObject = $cell;
86 + $this->_currentCellIsDirty = true;
87 +
88 + return $cell;
89 + } // function addCacheData()
90 +
91 +
92 + /**
93 + * Get cell at a specific coordinate
94 + *
95 + * @param string $pCoord Coordinate of the cell
96 + * @throws PHPExcel_Exception
97 + * @return PHPExcel_Cell Cell that was found, or null if not found
98 + */
99 + public function getCacheData($pCoord) {
100 + if ($pCoord === $this->_currentObjectID) {
101 + return $this->_currentObject;
102 + }
103 + $this->_storeData();
104 +
105 + $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
106 + $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
107 + if ($cellResultSet === false) {
108 + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
109 + } elseif ($cellResultSet->numRows() == 0) {
110 + // Return null if requested entry doesn't exist in cache
111 + return null;
112 + }
113 +
114 + // Set current entry to the requested entry
115 + $this->_currentObjectID = $pCoord;
116 +
117 + $cellResult = $cellResultSet->fetchSingle();
118 + $this->_currentObject = unserialize($cellResult);
119 + // Re-attach this as the cell's parent
120 + $this->_currentObject->attach($this);
121 +
122 + // Return requested entry
123 + return $this->_currentObject;
124 + } // function getCacheData()
125 +
126 +
127 + /**
128 + * Is a value set for an indexed cell?
129 + *
130 + * @param string $pCoord Coordinate address of the cell to check
131 + * @return boolean
132 + */
133 + public function isDataSet($pCoord) {
134 + if ($pCoord === $this->_currentObjectID) {
135 + return true;
136 + }
137 +
138 + // Check if the requested entry exists in the cache
139 + $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
140 + $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
141 + if ($cellResultSet === false) {
142 + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
143 + } elseif ($cellResultSet->numRows() == 0) {
144 + // Return null if requested entry doesn't exist in cache
145 + return false;
146 + }
147 + return true;
148 + } // function isDataSet()
149 +
150 +
151 + /**
152 + * Delete a cell in cache identified by coordinate address
153 + *
154 + * @param string $pCoord Coordinate address of the cell to delete
155 + * @throws PHPExcel_Exception
156 + */
157 + public function deleteCacheData($pCoord) {
158 + if ($pCoord === $this->_currentObjectID) {
159 + $this->_currentObject->detach();
160 + $this->_currentObjectID = $this->_currentObject = null;
161 + }
162 +
163 + // Check if the requested entry exists in the cache
164 + $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
165 + if (!$this->_DBHandle->queryExec($query))
166 + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
167 +
168 + $this->_currentCellIsDirty = false;
169 + } // function deleteCacheData()
170 +
171 +
172 + /**
173 + * Move a cell object from one address to another
174 + *
175 + * @param string $fromAddress Current address of the cell to move
176 + * @param string $toAddress Destination address of the cell to move
177 + * @return boolean
178 + */
179 + public function moveCell($fromAddress, $toAddress) {
180 + if ($fromAddress === $this->_currentObjectID) {
181 + $this->_currentObjectID = $toAddress;
182 + }
183 +
184 + $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";
185 + $result = $this->_DBHandle->exec($query);
186 + if ($result === false)
187 + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
188 +
189 + $query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
190 + $result = $this->_DBHandle->exec($query);
191 + if ($result === false)
192 + throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
193 +
194 + return TRUE;
195 + } // function moveCell()
196 +
197 +
198 + /**
199 + * Get a list of all cell addresses currently held in cache
200 + *
201 + * @return string[]
202 + */
203 + public function getCellList() {
204 + if ($this->_currentObjectID !== null) {
205 + $this->_storeData();
206 + }
207 +
208 + $query = "SELECT id FROM kvp_".$this->_TableName;
209 + $cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC);
210 + if ($cellIdsResult === false)
211 + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
212 +
213 + $cellKeys = array();
214 + foreach($cellIdsResult as $row) {
215 + $cellKeys[] = $row['id'];
216 + }
217 +
218 + return $cellKeys;
219 + } // function getCellList()
220 +
221 +
222 + /**
223 + * Clone the cell collection
224 + *
225 + * @param PHPExcel_Worksheet $parent The new worksheet
226 + * @return void
227 + */
228 + public function copyCellCollection(PHPExcel_Worksheet $parent) {
229 + $this->_currentCellIsDirty;
230 + $this->_storeData();
231 +
232 + // Get a new id for the new table name
233 + $tableName = str_replace('.','_',$this->_getUniqueID());
234 + if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
235 + AS SELECT * FROM kvp_'.$this->_TableName))
236 + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
237 +
238 + // Copy the existing cell cache file
239 + $this->_TableName = $tableName;
240 + } // function copyCellCollection()
241 +
242 +
243 + /**
244 + * Clear the cell collection and disconnect from our parent
245 + *
246 + * @return void
247 + */
248 + public function unsetWorksheetCells() {
249 + if(!is_null($this->_currentObject)) {
250 + $this->_currentObject->detach();
251 + $this->_currentObject = $this->_currentObjectID = null;
252 + }
253 + // detach ourself from the worksheet, so that it can then delete this object successfully
254 + $this->_parent = null;
255 +
256 + // Close down the temporary cache file
257 + $this->__destruct();
258 + } // function unsetWorksheetCells()
259 +
260 +
261 + /**
262 + * Initialise this new cell collection
263 + *
264 + * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
265 + */
266 + public function __construct(PHPExcel_Worksheet $parent) {
267 + parent::__construct($parent);
268 + if (is_null($this->_DBHandle)) {
269 + $this->_TableName = str_replace('.','_',$this->_getUniqueID());
270 + $_DBName = ':memory:';
271 +
272 + $this->_DBHandle = new SQLiteDatabase($_DBName);
273 + if ($this->_DBHandle === false)
274 + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
275 + if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
276 + throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
277 + }
278 + } // function __construct()
279 +
280 +
281 + /**
282 + * Destroy this cell collection
283 + */
284 + public function __destruct() {
285 + if (!is_null($this->_DBHandle)) {
286 + $this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName);
287 + }
288 + $this->_DBHandle = null;
289 + } // function __destruct()
290 +
291 +
292 + /**
293 + * Identify whether the caching method is currently available
294 + * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
295 + *
296 + * @return boolean
297 + */
298 + public static function cacheMethodIsAvailable() {
299 + if (!function_exists('sqlite_open')) {
300 + return false;
301 + }
302 +
303 + return true;
304 + }
305 +
306 +}