ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
PHPExcel_CachedObjectStorage_SQLite3 Class Reference
+ Inheritance diagram for PHPExcel_CachedObjectStorage_SQLite3:
+ Collaboration diagram for PHPExcel_CachedObjectStorage_SQLite3:

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)
 Get highest worksheet column. More...
 
 getHighestRow ($column=null)
 Get highest worksheet row. More...
 
 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
 updateCacheData (PHPExcel_Cell $cell)
 Add or Update a cell in cache. More...
 
 getSortedCellList ()
 Get the list of all cell addresses currently held in cache sorted by column and row. 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 Public Member Functions inherited from PHPExcel_CachedObjectStorage_CacheBase
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
 
 $_selectQuery
 
 $_insertQuery
 
 $_updateQuery
 
 $_deleteQuery
 

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 SQLite3.php.

Constructor & Destructor Documentation

◆ __construct()

PHPExcel_CachedObjectStorage_SQLite3::__construct ( PHPExcel_Worksheet  $parent)

Initialise this new cell collection.

Parameters
PHPExcel_Worksheet$parentThe worksheet for this cell collection

Definition at line 299 of file SQLite3.php.

References PHPExcel_CachedObjectStorage_CacheBase\_getUniqueID().

299  {
300  parent::__construct($parent);
301  if (is_null($this->_DBHandle)) {
302  $this->_TableName = str_replace('.','_',$this->_getUniqueID());
303  $_DBName = ':memory:';
304 
305  $this->_DBHandle = new SQLite3($_DBName);
306  if ($this->_DBHandle === false)
307  throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
308  if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
309  throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
310  }
311 
312  $this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id");
313  $this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");
314  $this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId");
315  $this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id");
316  } // function __construct()
_getUniqueID()
Generate a unique ID for cache referencing.
Definition: CacheBase.php:311
+ Here is the call graph for this function:

◆ __destruct()

PHPExcel_CachedObjectStorage_SQLite3::__destruct ( )

Destroy this cell collection.

Definition at line 322 of file SQLite3.php.

Referenced by unsetWorksheetCells().

322  {
323  if (!is_null($this->_DBHandle)) {
324  $this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName);
325  $this->_DBHandle->close();
326  }
327  $this->_DBHandle = null;
328  } // function __destruct()
+ Here is the caller graph for this function:

Member Function Documentation

◆ _storeData()

PHPExcel_CachedObjectStorage_SQLite3::_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 87 of file SQLite3.php.

References $result.

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

87  {
88  if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
89  $this->_currentObject->detach();
90 
91  $this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
92  $this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
93  $result = $this->_insertQuery->execute();
94  if ($result === false)
95  throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
96  $this->_currentCellIsDirty = false;
97  }
98  $this->_currentObjectID = $this->_currentObject = null;
99  } // function _storeData()
$result
+ Here is the caller graph for this function:

◆ addCacheData()

PHPExcel_CachedObjectStorage_SQLite3::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 110 of file SQLite3.php.

References _storeData().

110  {
111  if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
112  $this->_storeData();
113  }
114 
115  $this->_currentObjectID = $pCoord;
116  $this->_currentObject = $cell;
117  $this->_currentCellIsDirty = true;
118 
119  return $cell;
120  } // function addCacheData()
_storeData()
Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current c...
Definition: SQLite3.php:87
+ Here is the call graph for this function:

◆ cacheMethodIsAvailable()

static PHPExcel_CachedObjectStorage_SQLite3::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

Implements PHPExcel_CachedObjectStorage_ICache.

Definition at line 337 of file SQLite3.php.

337  {
338  if (!class_exists('SQLite3',FALSE)) {
339  return false;
340  }
341 
342  return true;
343  }

◆ copyCellCollection()

PHPExcel_CachedObjectStorage_SQLite3::copyCellCollection ( PHPExcel_Worksheet  $parent)

Clone the cell collection.

Parameters
PHPExcel_Worksheet$parentThe new worksheet
Returns
void

Implements PHPExcel_CachedObjectStorage_ICache.

Definition at line 261 of file SQLite3.php.

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

261  {
263  $this->_storeData();
264 
265  // Get a new id for the new table name
266  $tableName = str_replace('.','_',$this->_getUniqueID());
267  if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
268  AS SELECT * FROM kvp_'.$this->_TableName))
269  throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
270 
271  // Copy the existing cell cache file
272  $this->_TableName = $tableName;
273  } // function copyCellCollection()
_storeData()
Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current c...
Definition: SQLite3.php:87
_getUniqueID()
Generate a unique ID for cache referencing.
Definition: CacheBase.php:311
+ Here is the call graph for this function:

◆ deleteCacheData()

PHPExcel_CachedObjectStorage_SQLite3::deleteCacheData (   $pCoord)

Delete a cell in cache identified by coordinate address.

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

Implements PHPExcel_CachedObjectStorage_ICache.

Definition at line 188 of file SQLite3.php.

References $result.

188  {
189  if ($pCoord === $this->_currentObjectID) {
190  $this->_currentObject->detach();
191  $this->_currentObjectID = $this->_currentObject = NULL;
192  }
193 
194  // Check if the requested entry exists in the cache
195  $this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
196  $result = $this->_deleteQuery->execute();
197  if ($result === FALSE)
198  throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
199 
200  $this->_currentCellIsDirty = FALSE;
201  } // function deleteCacheData()
$result

◆ getCacheData()

PHPExcel_CachedObjectStorage_SQLite3::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 130 of file SQLite3.php.

References PHPExcel_CachedObjectStorage_CacheBase\$_currentObject, and _storeData().

130  {
131  if ($pCoord === $this->_currentObjectID) {
132  return $this->_currentObject;
133  }
134  $this->_storeData();
135 
136  $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
137  $cellResult = $this->_selectQuery->execute();
138  if ($cellResult === FALSE) {
139  throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
140  }
141  $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
142  if ($cellData === FALSE) {
143  // Return null if requested entry doesn't exist in cache
144  return NULL;
145  }
146 
147  // Set current entry to the requested entry
148  $this->_currentObjectID = $pCoord;
149 
150  $this->_currentObject = unserialize($cellData['value']);
151  // Re-attach this as the cell's parent
152  $this->_currentObject->attach($this);
153 
154  // Return requested entry
155  return $this->_currentObject;
156  } // function getCacheData()
_storeData()
Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current c...
Definition: SQLite3.php:87
+ Here is the call graph for this function:

◆ getCellList()

PHPExcel_CachedObjectStorage_SQLite3::getCellList ( )

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

Returns
string[]

Implements PHPExcel_CachedObjectStorage_ICache.

Definition at line 236 of file SQLite3.php.

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

236  {
237  if ($this->_currentObjectID !== null) {
238  $this->_storeData();
239  }
240 
241  $query = "SELECT id FROM kvp_".$this->_TableName;
242  $cellIdsResult = $this->_DBHandle->query($query);
243  if ($cellIdsResult === false)
244  throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
245 
246  $cellKeys = array();
247  while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
248  $cellKeys[] = $row['id'];
249  }
250 
251  return $cellKeys;
252  } // function getCellList()
_storeData()
Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current c...
Definition: SQLite3.php:87
$query
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ isDataSet()

PHPExcel_CachedObjectStorage_SQLite3::isDataSet (   $pCoord)

Is a value set for an indexed cell?

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

Implements PHPExcel_CachedObjectStorage_ICache.

Definition at line 165 of file SQLite3.php.

165  {
166  if ($pCoord === $this->_currentObjectID) {
167  return TRUE;
168  }
169 
170  // Check if the requested entry exists in the cache
171  $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
172  $cellResult = $this->_selectQuery->execute();
173  if ($cellResult === FALSE) {
174  throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
175  }
176  $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
177 
178  return ($cellData === FALSE) ? FALSE : TRUE;
179  } // function isDataSet()

◆ moveCell()

PHPExcel_CachedObjectStorage_SQLite3::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

Definition at line 211 of file SQLite3.php.

References $result, and $toAddress.

211  {
212  if ($fromAddress === $this->_currentObjectID) {
213  $this->_currentObjectID = $toAddress;
214  }
215 
216  $this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT);
217  $result = $this->_deleteQuery->execute();
218  if ($result === false)
219  throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
220 
221  $this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT);
222  $this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT);
223  $result = $this->_updateQuery->execute();
224  if ($result === false)
225  throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
226 
227  return TRUE;
228  } // function moveCell()
$result
$toAddress

◆ unsetWorksheetCells()

PHPExcel_CachedObjectStorage_SQLite3::unsetWorksheetCells ( )

Clear the cell collection and disconnect from our parent.

Returns
void

Definition at line 281 of file SQLite3.php.

References __destruct().

281  {
282  if(!is_null($this->_currentObject)) {
283  $this->_currentObject->detach();
284  $this->_currentObject = $this->_currentObjectID = null;
285  }
286  // detach ourself from the worksheet, so that it can then delete this object successfully
287  $this->_parent = null;
288 
289  // Close down the temporary cache file
290  $this->__destruct();
291  } // function unsetWorksheetCells()
__destruct()
Destroy this cell collection.
Definition: SQLite3.php:322
+ Here is the call graph for this function:

Field Documentation

◆ $_DBHandle

PHPExcel_CachedObjectStorage_SQLite3::$_DBHandle = null
private

Definition at line 50 of file SQLite3.php.

◆ $_deleteQuery

PHPExcel_CachedObjectStorage_SQLite3::$_deleteQuery
private

Definition at line 78 of file SQLite3.php.

◆ $_insertQuery

PHPExcel_CachedObjectStorage_SQLite3::$_insertQuery
private

Definition at line 64 of file SQLite3.php.

◆ $_selectQuery

PHPExcel_CachedObjectStorage_SQLite3::$_selectQuery
private

Definition at line 57 of file SQLite3.php.

◆ $_TableName

PHPExcel_CachedObjectStorage_SQLite3::$_TableName = null
private

Definition at line 43 of file SQLite3.php.

◆ $_updateQuery

PHPExcel_CachedObjectStorage_SQLite3::$_updateQuery
private

Definition at line 71 of file SQLite3.php.


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