Public Member Functions | |
readFromFile ($file=null) | |
Read LOB data from file. | |
writeToFile ($file=null) | |
Write LOB data to file. | |
dump () | |
Dump the contents of the file using fpassthru(). |
Definition at line 31 of file Clob.php.
Clob::dump | ( | ) |
Dump the contents of the file using fpassthru().
Exception | if no file or contents. |
Reimplemented from Lob.
Definition at line 88 of file Clob.php.
00089 { 00090 if (!$this->data) { 00091 00092 // is there a file name set? 00093 if ($this->inFile) { 00094 $fp = @fopen($this->inFile, "r"); 00095 if (!$fp) { 00096 throw new Exception('Unable to open file: '.$this->inFile); 00097 } 00098 fpassthru($fp); 00099 @fclose($fp); 00100 } else { 00101 throw new Exception('No data to dump'); 00102 } 00103 00104 } else { 00105 echo $this->data; 00106 } 00107 00108 }
Clob::readFromFile | ( | $ | file = null |
) |
Read LOB data from file.
string | $file Filename may also be specified here (if not specified using setInputFile()). |
Exception | - if no file specified or error on read. |
Reimplemented from Lob.
Definition at line 40 of file Clob.php.
References Lob::$data, Lob::setContents(), and Lob::setInputFile().
00041 { 00042 if ($file !== null) { 00043 $this->setInputFile($file); 00044 } 00045 if (!$this->inFile) { 00046 throw Exception('No file specified for read.'); 00047 } 00048 $data = null; 00049 $file = fopen($this->inFile, "rt"); 00050 while (!feof($file)) $data .= fgets($file, 4096); 00051 fclose($file); 00052 if ($data === false) { 00053 throw new Exception('Unable to read from file: '.$this->inFile); 00054 } 00055 $this->setContents($data); 00056 }
Clob::writeToFile | ( | $ | file = null |
) |
Write LOB data to file.
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 from Lob.
Definition at line 65 of file Clob.php.
References Lob::setOutputFile().
00066 { 00067 if ($file !== null) { 00068 $this->setOutputFile($file); 00069 } 00070 if (!$this->outFile) { 00071 throw new Exception('No file specified for write'); 00072 } 00073 if ($this->data === null) { 00074 throw new Exception('No data to write to file'); 00075 } 00076 $file = fopen($this->inFile, "wt"); 00077 if (fputs($file, $this->data) === false) 00078 throw new Exception('Unable to write to file: '.$this->outFile); 00079 fclose($file); 00080 }