ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PHPExcel_CachedObjectStorage_SQLite Class Reference
+ Inheritance diagram for PHPExcel_CachedObjectStorage_SQLite:
+ Collaboration diagram for PHPExcel_CachedObjectStorage_SQLite:

Public Member Functions

 addCacheData ($pCoord, PHPExcel_Cell $cell)
 Add or Update a cell in cache identified by coordinate address. More...
 
 getCacheData ($pCoord)
 Get cell at a specific coordinate. More...
 
 isDataSet ($pCoord)
 Is a value set for an indexed cell? More...
 
 deleteCacheData ($pCoord)
 Delete a cell in cache identified by coordinate address. More...
 
 moveCell ($fromAddress, $toAddress)
 Move a cell object from one address to another. More...
 
 getCellList ()
 Get a list of all cell addresses currently held in cache. More...
 
 copyCellCollection (PHPExcel_Worksheet $parent)
 Clone the cell collection. More...
 
 unsetWorksheetCells ()
 Clear the cell collection and disconnect from our parent. More...
 
 __construct (PHPExcel_Worksheet $parent)
 Initialise this new cell collection. More...
 
 __destruct ()
 Destroy this cell collection. More...
 
- Public Member Functions inherited from PHPExcel_CachedObjectStorage_CacheBase
 __construct (PHPExcel_Worksheet $parent)
 Initialise this new cell collection. More...
 
 getParent ()
 Return the parent worksheet for this cell collection. More...
 
 isDataSet ($pCoord)
 Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? More...
 
 moveCell ($fromAddress, $toAddress)
 Move a cell object from one address to another. More...
 
 updateCacheData (PHPExcel_Cell $cell)
 Add or Update a cell in cache. More...
 
 deleteCacheData ($pCoord)
 Delete a cell in cache identified by coordinate address. More...
 
 getCellList ()
 Get a list of all cell addresses currently held in cache. More...
 
 getSortedCellList ()
 Sort the list of all cell addresses currently held in cache by row and column. More...
 
 getHighestRowAndColumn ()
 Get highest worksheet column and highest row that have cell records. More...
 
 getCurrentAddress ()
 Return the cell address of the currently active cell object. More...
 
 getCurrentColumn ()
 Return the column address of the currently active cell object. More...
 
 getCurrentRow ()
 Return the row address of the currently active cell object. More...
 
 getHighestColumn ($row=null)
 
 getHighestRow ($column=null)
 
 copyCellCollection (PHPExcel_Worksheet $parent)
 Clone the cell collection. More...
 
 removeRow ($row)
 Remove a row, deleting all cells in that row. More...
 
 removeColumn ($column)
 Remove a column, deleting all cells in that column. More...
 
- Public Member Functions inherited from PHPExcel_CachedObjectStorage_ICache
 addCacheData ($pCoord, PHPExcel_Cell $cell)
 Add or Update a cell in cache identified by coordinate address. More...
 
 updateCacheData (PHPExcel_Cell $cell)
 Add or Update a cell in cache. More...
 
 getCacheData ($pCoord)
 Fetch a cell from cache identified by coordinate address. More...
 
 deleteCacheData ($pCoord)
 Delete a cell in cache identified by coordinate address. More...
 
 isDataSet ($pCoord)
 Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? More...
 
 getCellList ()
 Get a list of all cell addresses currently held in cache. More...
 
 getSortedCellList ()
 Get the list of all cell addresses currently held in cache sorted by column and row. More...
 
 copyCellCollection (PHPExcel_Worksheet $parent)
 Clone the cell collection. More...
 

Static Public Member Functions

static cacheMethodIsAvailable ()
 Identify whether the caching method is currently available Some methods are dependent on the availability of certain extensions being enabled in the PHP build. More...
 
static cacheMethodIsAvailable ()
 Identify whether the caching method is currently available Some methods are dependent on the availability of certain extensions being enabled in the PHP build. More...
 
static cacheMethodIsAvailable ()
 Identify whether the caching method is currently available Some methods are dependent on the availability of certain extensions being enabled in the PHP build. More...
 

Protected Member Functions

 _storeData ()
 Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current cell object. More...
 
- Protected Member Functions inherited from PHPExcel_CachedObjectStorage_CacheBase
 _getUniqueID ()
 Generate a unique ID for cache referencing. More...
 

Private Attributes

 $_TableName = null
 
 $_DBHandle = null
 

Additional Inherited Members

- Protected Attributes inherited from PHPExcel_CachedObjectStorage_CacheBase
 $_parent
 
 $_currentObject = null
 
 $_currentObjectID = null
 
 $_currentCellIsDirty = true
 
 $_cellCache = array()
 

Detailed Description

Definition at line 36 of file SQLite.php.

Constructor & Destructor Documentation

◆ __construct()

PHPExcel_CachedObjectStorage_SQLite::__construct ( PHPExcel_Worksheet  $parent)

Initialise this new cell collection.

Parameters
PHPExcel_Worksheet$parentThe worksheet for this cell collection

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 266 of file SQLite.php.

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 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()
_getUniqueID()
Generate a unique ID for cache referencing.
Definition: CacheBase.php:311

References PHPExcel_CachedObjectStorage_CacheBase\_getUniqueID().

+ Here is the call graph for this function:

◆ __destruct()

PHPExcel_CachedObjectStorage_SQLite::__destruct ( )

Destroy this cell collection.

Definition at line 284 of file SQLite.php.

284 {
285 if (!is_null($this->_DBHandle)) {
286 $this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName);
287 }
288 $this->_DBHandle = null;
289 } // function __destruct()

Referenced by unsetWorksheetCells().

+ Here is the caller graph for this function:

Member Function Documentation

◆ _storeData()

PHPExcel_CachedObjectStorage_SQLite::_storeData ( )
protected

Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current cell object.

Returns
void
Exceptions
PHPExcel_Exception

Definition at line 59 of file SQLite.php.

59 {
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()

Referenced by addCacheData(), copyCellCollection(), getCacheData(), and getCellList().

+ Here is the caller graph for this function:

◆ addCacheData()

PHPExcel_CachedObjectStorage_SQLite::addCacheData (   $pCoord,
PHPExcel_Cell  $cell 
)

Add or Update a cell in cache identified by coordinate address.

Parameters
string$pCoordCoordinate address of the cell to update
PHPExcel_Cell$cellCell to update
Returns
PHPExcel_Cell
Exceptions
PHPExcel_Exception

Implements PHPExcel_CachedObjectStorage_ICache.

Definition at line 79 of file SQLite.php.

79 {
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()
_storeData()
Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current c...
Definition: SQLite.php:59

References _storeData().

+ Here is the call graph for this function:

◆ cacheMethodIsAvailable()

static PHPExcel_CachedObjectStorage_SQLite::cacheMethodIsAvailable ( )
static

Identify whether the caching method is currently available Some methods are dependent on the availability of certain extensions being enabled in the PHP build.

Returns
boolean

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 298 of file SQLite.php.

298 {
299 if (!function_exists('sqlite_open')) {
300 return false;
301 }
302
303 return true;
304 }

◆ copyCellCollection()

PHPExcel_CachedObjectStorage_SQLite::copyCellCollection ( PHPExcel_Worksheet  $parent)

Clone the cell collection.

Parameters
PHPExcel_Worksheet$parentThe new worksheet
Returns
void

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 228 of file SQLite.php.

228 {
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()

References PHPExcel_CachedObjectStorage_CacheBase\$_currentCellIsDirty, PHPExcel_CachedObjectStorage_CacheBase\_getUniqueID(), and _storeData().

+ Here is the call graph for this function:

◆ deleteCacheData()

PHPExcel_CachedObjectStorage_SQLite::deleteCacheData (   $pCoord)

Delete a cell in cache identified by coordinate address.

Parameters
string$pCoordCoordinate address of the cell to delete
Exceptions
PHPExcel_Exception

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 157 of file SQLite.php.

157 {
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()

References $query.

◆ getCacheData()

PHPExcel_CachedObjectStorage_SQLite::getCacheData (   $pCoord)

Get cell at a specific coordinate.

Parameters
string$pCoordCoordinate of the cell
Exceptions
PHPExcel_Exception
Returns
PHPExcel_Cell Cell that was found, or null if not found

Implements PHPExcel_CachedObjectStorage_ICache.

Definition at line 99 of file SQLite.php.

99 {
100 if ($pCoord === $this->_currentObjectID) {
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
124 } // function getCacheData()

References PHPExcel_CachedObjectStorage_CacheBase\$_currentObject, $query, and _storeData().

+ Here is the call graph for this function:

◆ getCellList()

PHPExcel_CachedObjectStorage_SQLite::getCellList ( )

Get a list of all cell addresses currently held in cache.

Returns
string[]

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 203 of file SQLite.php.

203 {
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()

References $query, $row, and _storeData().

+ Here is the call graph for this function:

◆ isDataSet()

PHPExcel_CachedObjectStorage_SQLite::isDataSet (   $pCoord)

Is a value set for an indexed cell?

Parameters
string$pCoordCoordinate address of the cell to check
Returns
boolean

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 133 of file SQLite.php.

133 {
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()

References $query.

◆ moveCell()

PHPExcel_CachedObjectStorage_SQLite::moveCell (   $fromAddress,
  $toAddress 
)

Move a cell object from one address to another.

Parameters
string$fromAddressCurrent address of the cell to move
string$toAddressDestination address of the cell to move
Returns
boolean

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 179 of file SQLite.php.

179 {
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()
$result

References $query, and $result.

◆ unsetWorksheetCells()

PHPExcel_CachedObjectStorage_SQLite::unsetWorksheetCells ( )

Clear the cell collection and disconnect from our parent.

Returns
void

Definition at line 248 of file SQLite.php.

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 } // function unsetWorksheetCells()
__destruct()
Destroy this cell collection.
Definition: SQLite.php:284

References __destruct().

+ Here is the call graph for this function:

Field Documentation

◆ $_DBHandle

PHPExcel_CachedObjectStorage_SQLite::$_DBHandle = null
private

Definition at line 50 of file SQLite.php.

◆ $_TableName

PHPExcel_CachedObjectStorage_SQLite::$_TableName = null
private

Definition at line 43 of file SQLite.php.


The documentation for this class was generated from the following file: