Add move cell method for SQLite.

TODO - modify SQLite3 to use parameterised statements consistently throughout
This commit is contained in:
Mark Baker 2013-02-27 23:13:49 +00:00
parent 4e52db40dd
commit ae9d9fd758
3 changed files with 54 additions and 1 deletions

View File

@ -117,13 +117,14 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
if ($fromAddress === $this->_currentObjectID) {
$this->_currentObjectID = $toAddress;
}
$this->_currentCellIsDirty = true;
if (isset($this->_cellCache[$fromAddress])) {
$this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress];
unset($this->_cellCache[$fromAddress]);
}
return TRUE;
} // function isDataSet()
} // function moveCell()
/**

View File

@ -169,6 +169,32 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
} // function deleteCacheData()
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress) {
if ($fromAddress === $this->_currentObjectID) {
$this->_currentObjectID = $toAddress;
}
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";
$result = $this->_DBHandle->exec($query);
if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
$query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
$result = $this->_DBHandle->exec($query);
if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
return TRUE;
} // function moveCell()
/**
* Get a list of all cell addresses currently held in cache
*

View File

@ -173,6 +173,32 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
} // function deleteCacheData()
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress) {
if ($fromAddress === $this->_currentObjectID) {
$this->_currentObjectID = $toAddress;
}
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";
$result = $this->_DBHandle->exec($query);
if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
$query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
$result = $this->_DBHandle->exec($query);
if ($result === false)
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
return TRUE;
} // function moveCell()
/**
* Get a list of all cell addresses currently held in cache
*