File::CSV patch
| From: | Yavor Shahpasov | Date: | Wed, 11 Dec 2002 11:49:17 +0000 |
| Subject: | File::CSV patch | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-11551@lists.php.net to get a copy of this message | ||
It seems that the File::CSV by default overwrites the File given
File_CSV::write($cvs_file, array_values($data), $conf);
this would overwrite the file with the new contents, it seems more logical
to me the data to be appended to the file. I have provided a patch which
fixes this. Can someone have a look at it and commit if it is ok.
Yavor
See below
--- CSV.php Wed Dec 11 13:44:16 2002
+++ CSV.php.orig Fri Nov 22 19:26:00 2002
@@ -108,7 +108,7 @@
*
* @param string $file The name of the file
* @param array &$conf The configuration
- * @param string $mode The open node (ex: FILE_MODE_READ or
FILE_MODE_WRITE or FILE_MODE_APPEND)
+ * @param string $mode The open node (ex: FILE_MODE_READ or
FILE_MODE_WRITE)
*
* @return mixed A file resource or false
*/
@@ -312,13 +312,12 @@
* @param string $file The filename where to write the data
* @param array $fields Ordered array with the data
* @param array &$conf The configuration of the dest CSV
- * @param string $mode The open node (ex: FILE_MODE_READ or
FILE_MODE_WRITE or FILE_MODE_APPEND)
*
* @return bool True on success false otherwise
*/
- function write($file, $fields, &$conf, $mode = FILE_MODE_APPEND)
+ function write($file, $fields, &$conf)
{
- if (!$fp = File_CSV::getPointer($file, $conf, $mode)) {
+ if (!$fp = File_CSV::getPointer($file, $conf, FILE_MODE_WRITE)) {
return false;
}
if (count($fields) != $conf['fields']) {