88 if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
89 $this->_currentObject->detach();
91 $this->_insertQuery->bindValue(
'id',$this->_currentObjectID,SQLITE3_TEXT);
92 $this->_insertQuery->bindValue(
'data',serialize($this->_currentObject),SQLITE3_BLOB);
93 $result = $this->_insertQuery->execute();
96 $this->_currentCellIsDirty =
false;
98 $this->_currentObjectID = $this->_currentObject = null;
111 if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
115 $this->_currentObjectID = $pCoord;
116 $this->_currentObject = $cell;
117 $this->_currentCellIsDirty =
true;
131 if ($pCoord === $this->_currentObjectID) {
136 $this->_selectQuery->bindValue(
'id',$pCoord,SQLITE3_TEXT);
137 $cellResult = $this->_selectQuery->execute();
138 if ($cellResult === FALSE) {
141 $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
142 if ($cellData === FALSE) {
148 $this->_currentObjectID = $pCoord;
150 $this->_currentObject = unserialize($cellData[
'value']);
152 $this->_currentObject->attach($this);
166 if ($pCoord === $this->_currentObjectID) {
171 $this->_selectQuery->bindValue(
'id',$pCoord,SQLITE3_TEXT);
172 $cellResult = $this->_selectQuery->execute();
173 if ($cellResult === FALSE) {
176 $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
178 return ($cellData === FALSE) ? FALSE : TRUE;
189 if ($pCoord === $this->_currentObjectID) {
190 $this->_currentObject->detach();
191 $this->_currentObjectID = $this->_currentObject = NULL;
195 $this->_deleteQuery->bindValue(
'id',$pCoord,SQLITE3_TEXT);
196 $result = $this->_deleteQuery->execute();
200 $this->_currentCellIsDirty = FALSE;
211 public function moveCell($fromAddress, $toAddress) {
212 if ($fromAddress === $this->_currentObjectID) {
213 $this->_currentObjectID = $toAddress;
216 $this->_deleteQuery->bindValue(
'id',$toAddress,SQLITE3_TEXT);
217 $result = $this->_deleteQuery->execute();
221 $this->_updateQuery->bindValue(
'toid',$toAddress,SQLITE3_TEXT);
222 $this->_updateQuery->bindValue(
'fromid',$fromAddress,SQLITE3_TEXT);
223 $result = $this->_updateQuery->execute();
237 if ($this->_currentObjectID !== null) {
241 $query =
"SELECT id FROM kvp_".$this->_TableName;
242 $cellIdsResult = $this->_DBHandle->query(
$query);
243 if ($cellIdsResult ===
false)
247 while (
$row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
248 $cellKeys[] =
$row[
'id'];
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))
272 $this->_TableName = $tableName;
282 if(!is_null($this->_currentObject)) {
283 $this->_currentObject->detach();
284 $this->_currentObject = $this->_currentObjectID = null;
287 $this->_parent = null;
300 parent::__construct($parent);
301 if (is_null($this->_DBHandle)) {
302 $this->_TableName = str_replace(
'.',
'_',$this->
_getUniqueID());
303 $_DBName =
':memory:';
305 $this->_DBHandle =
new SQLite3($_DBName);
306 if ($this->_DBHandle ===
false)
308 if (!$this->_DBHandle->exec(
'CREATE TABLE kvp_'.$this->_TableName.
' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
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");
323 if (!is_null($this->_DBHandle)) {
324 $this->_DBHandle->exec(
'DROP TABLE kvp_'.$this->_TableName);
325 $this->_DBHandle->close();
327 $this->_DBHandle = null;
338 if (!class_exists(
'SQLite3',FALSE)) {
addCacheData($pCoord, PHPExcel_Cell $cell)
Add or Update a cell in cache identified by coordinate address.
deleteCacheData($pCoord)
Delete a cell in cache identified by coordinate address.
_storeData()
Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current c...
isDataSet($pCoord)
Is a value set for an indexed cell?
static cacheMethodIsAvailable()
Identify whether the caching method is currently available Some methods are dependent on the availabi...
getCellList()
Get a list of all cell addresses currently held in cache.
moveCell($fromAddress, $toAddress)
Move a cell object from one address to another.
unsetWorksheetCells()
Clear the cell collection and disconnect from our parent.
getCacheData($pCoord)
Get cell at a specific coordinate.
_getUniqueID()
Generate a unique ID for cache referencing.
__construct(PHPExcel_Worksheet $parent)
Initialise this new cell collection.
copyCellCollection(PHPExcel_Worksheet $parent)
Clone the cell collection.
Create styles array
The data for the language used.
__destruct()
Destroy this cell collection.