From ae00f949f006f47d03b0e319eb50286a6df79d21 Mon Sep 17 00:00:00 2001 From: zynode Date: Mon, 31 Mar 2008 22:50:36 +0000 Subject: [PATCH] parseCSV 0.3.2 This is primarily a bug-fix release for a critical bug which was brought to my attention. - Fixed a critical bug in conditions parsing which would generate corrupt matching patterns causing the condition(s) to not work at all in some situations. - Fixed a small code error which would cause PHP to generate a invalid offset notice when zero length values were fed into the unparse() method to generate CSV data from an array. git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@22 339761fc-0c37-0410-822d-8b8cac1f6a97 --- ChangeLog.txt | 29 +++++++++++++++++++++++++++++ examples/basic.php | 6 +++++- parsecsv.lib.php | 8 ++++---- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index b8deb57..46741e3 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,29 @@ +parseCSV 0.3.2 +----------------------------------- +Date: 1-Apr-2008 + +This is primarily a bug-fix release for a critical +bug which was brought to my attention. + +- Fixed a critical bug in conditions parsing which + would generate corrupt matching patterns causing + the condition(s) to not work at all in some + situations. + +- Fixed a small code error which would cause PHP to + generate a invalid offset notice when zero length + values were fed into the unparse() method to + generate CSV data from an array. + +Notice: If you have been using the "parsecsv-stable" +branch as an external in any of your projects, +please use the "stable/parsecsv" branch from this +point on as I will eventually remove the former due +to it's stupid naming. + +----------------------------------- + + parseCSV 0.3.1 ----------------------------------- Date: 1-Sep-2007 @@ -31,6 +57,9 @@ Date: 9-Aug-2007 - Minor changes and optimizations, and a few spelling corrections. Oops :) +- Included more complex code examples in the + parseCSV download. + ----------------------------------- diff --git a/examples/basic.php b/examples/basic.php index 1dd6f2a..e29bdec 100644 --- a/examples/basic.php +++ b/examples/basic.php @@ -13,7 +13,11 @@ $csv = new parseCSV(); # Parse '_books.csv' using automatic delimiter detection... $csv->auto('_books.csv'); -# ...or if you know the delimiter, use the parse() function. +# ...or if you know the delimiter, set the delimiter character +# if its not the default comma... +// $csv->delimiter = "\t"; # tab delimited + +# ...and then use the parse() function. // $csv->parse('_books.csv'); diff --git a/parsecsv.lib.php b/parsecsv.lib.php index 6e9f19c..c5941b9 100644 --- a/parsecsv.lib.php +++ b/parsecsv.lib.php @@ -4,7 +4,7 @@ class parseCSV { /* - Class: parseCSV v0.3.2 beta + Class: parseCSV v0.3.2 http://code.google.com/p/parsecsv-for-php/ @@ -503,11 +503,11 @@ class parseCSV { function _validate_row_conditions ($row = array(), $conditions = null) { if ( !empty($row) ) { if ( !empty($conditions) ) { - $conditions = (strpos($conditions, 'OR') !== false) ? explode('OR', $conditions) : array($conditions) ; + $conditions = (strpos($conditions, ' OR ') !== false) ? explode(' OR ', $conditions) : array($conditions) ; $or = ''; foreach( $conditions as $key => $value ) { - if ( strpos($value, 'AND') !== false ) { - $value = explode('AND', $value); + if ( strpos($value, ' AND ') !== false ) { + $value = explode(' AND ', $value); $and = ''; foreach( $value as $k => $v ) { $and .= $this->_validate_row_condition($row, $v);