Public Member Functions | |
__construct ($data=null) | |
Construct a new Lob. | |
getContents () | |
Get the contents of the LOB. | |
setContents ($data) | |
Set the contents of this LOB. | |
dump () | |
Dump the contents of the file to stdout. | |
setInputFile ($filePath) | |
Specify the file that we want this LOB read from. | |
getInputFile () | |
Get the file that we want this LOB read from. | |
setOutputFile ($filePath) | |
Specify the file that we want this LOB saved to. | |
getOutputFile () | |
Get the file that we want this LOB saved to. | |
isFromFile () | |
Returns whether this Lob is loaded from file. | |
readFromFile ($file=null) | |
Read LOB data from file (binary safe). | |
writeToFile ($file=null) | |
Write LOB data to file (binary safe). | |
__toString () | |
Convenience method to get contents of LOB as string. | |
setModified ($b) | |
Set whether LOB contents have been modified after initial setting. | |
isModified () | |
Whether LOB contents have been modified after initial setting. | |
Protected Attributes | |
$data | |
$outFile | |
$inFile | |
Private Attributes | |
$modified = null |
Definition at line 29 of file Lob.php.
Lob::__construct | ( | $ | data = null |
) |
Construct a new Lob.
sttring | $data The data contents of the Lob. |
Definition at line 66 of file Lob.php.
References $data, and setContents().
00067 { 00068 if ($data !== null) { 00069 $this->setContents($data); 00070 } 00071 }
Lob::__toString | ( | ) |
Convenience method to get contents of LOB as string.
Definition at line 219 of file Lob.php.
References getContents().
00220 { 00221 return $this->getContents(); 00222 }
Lob::dump | ( | ) | [abstract] |
Lob::getContents | ( | ) |
Get the contents of the LOB.
Exception |
Definition at line 78 of file Lob.php.
References isFromFile(), and readFromFile().
Referenced by __toString().
00079 { 00080 if ($this->data === null && $this->isFromFile()) { 00081 $this->readFromFile(); 00082 } 00083 return $this->data; 00084 }
Lob::getInputFile | ( | ) |
Lob::getOutputFile | ( | ) |
Lob::isFromFile | ( | ) |
Returns whether this Lob is loaded from file.
This is useful for bypassing need to read in the contents of the Lob.
Definition at line 162 of file Lob.php.
Referenced by getContents().
Lob::isModified | ( | ) |
Whether LOB contents have been modified after initial setting.
Definition at line 238 of file Lob.php.
00239 { 00240 // cast it so that NULL will also eval to false 00241 return (boolean) $this->modified; 00242 }
Lob::readFromFile | ( | $ | file = null |
) |
Read LOB data from file (binary safe).
(Implementation may need to be moved into Clob / Blob subclasses, but since file_get_contents() is binary-safe, it hasn't been necessary so far.)
string | $file Filename may also be specified here (if not specified using setInputFile()). |
Exception | - if no file specified or error on read. |
Reimplemented in Clob.
Definition at line 176 of file Lob.php.
References $data, setContents(), and setInputFile().
Referenced by getContents().
00177 { 00178 if ($file !== null) { 00179 $this->setInputFile($file); 00180 } 00181 if (!$this->inFile) { 00182 throw Exception('No file specified for read.'); 00183 } 00184 $data = @file_get_contents($this->inFile); 00185 if ($data === false) { 00186 throw new Exception('Unable to read from file: '.$this->inFile); 00187 } 00188 $this->setContents($data); 00189 }
Lob::setContents | ( | $ | data | ) |
Set the contents of this LOB.
Sets the modified flag to FALSE if this is the first call to setContents() for this object. Sets the bit to TRUE if this any subsequent call to setContents().
string | $bytes |
Definition at line 93 of file Lob.php.
References $data.
Referenced by __construct(), readFromFile(), and Clob::readFromFile().
00094 { 00095 $this->data = $data; 00096 00097 if ($this->modified === null) { 00098 // if modified bit hasn't been set yet, 00099 // then it should now be set to FALSE, since 00100 // we just did inital population 00101 $this->modified = false; 00102 } elseif ($this->modified === false) { 00103 // if it was already FALSE, then it should 00104 // now be set to TRUE, since this is a subsequent 00105 // modfiication. 00106 $this->modified = true; 00107 } 00108 }
Lob::setInputFile | ( | $ | filePath | ) |
Specify the file that we want this LOB read from.
string | $filePath The location of the file. |
Definition at line 124 of file Lob.php.
Referenced by readFromFile(), and Clob::readFromFile().
Lob::setModified | ( | $ | b | ) |
Lob::setOutputFile | ( | $ | filePath | ) |
Specify the file that we want this LOB saved to.
string | $filePath The location of the file. |
Definition at line 143 of file Lob.php.
Referenced by writeToFile(), and Clob::writeToFile().
Lob::writeToFile | ( | $ | file = null |
) |
Write LOB data to file (binary safe).
(Impl may need to move into subclasses, but so far not necessary.)
string | $file Filename may also be specified here (if not set using setOutputFile()). |
Exception | - if no file specified, no contents to write, or error on write. |
Reimplemented in Clob.
Definition at line 199 of file Lob.php.
References setOutputFile().
00200 { 00201 if ($file !== null) { 00202 $this->setOutputFile($file); 00203 } 00204 if (!$this->outFile) { 00205 throw new Exception('No file specified for write'); 00206 } 00207 if ($this->data === null) { 00208 throw new Exception('No data to write to file'); 00209 } 00210 if (false === @file_put_contents($this->outFile, $this->data)) { 00211 throw new Exception('Unable to write to file: '.$this->outFile); 00212 } 00213 }
Lob::$data [protected] |
Definition at line 37 of file Lob.php.
Referenced by __construct(), readFromFile(), Clob::readFromFile(), and setContents().