cvs: pear /Structures_DataGrid package2.xml /Structures_DataGrid/DataGrid DataSource.php
| From: | Mark Wiesemann | Date: | Sun, 06 Apr 2008 15:24:29 +0000 |
| Subject: | cvs: pear /Structures_DataGrid package2.xml /Structures_DataGrid/DataGrid DataSource.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-51823@lists.php.net to get a copy of this message | ||
wiesemann Sun Apr 6 15:24:29 2008 UTC
Modified files:
/pear/Structures_DataGrid package2.xml
/pear/Structures_DataGrid/DataGrid DataSource.php
Log:
- better handling of quoting identifiers (detection of dots; no new option required anymore; c.p.
Bug #13025
- fix my fix for Bug #13339 (ORDER BY detection)
http://cvs.php.net/viewvc.cgi/pear/Structures_DataGrid/package2.xml?r1=1.62&r2=1.63&diff_format=u
Index: pear/Structures_DataGrid/package2.xml
diff -u pear/Structures_DataGrid/package2.xml:1.62 pear/Structures_DataGrid/package2.xml:1.63
--- pear/Structures_DataGrid/package2.xml:1.62 Sun Apr 6 14:43:29 2008
+++ pear/Structures_DataGrid/package2.xml Sun Apr 6 15:24:29 2008
@@ -47,8 +47,7 @@
<license uri="http://opensource.org/licenses/bsd-license.php">New
BSD</license>
<notes>
- Bug #13025: field names in the form "table.field" could lead to syntax errors
- in the SQL queries of the DBQuery, MDB2, and PDO DataSource drivers; new
- option 'quote_identifiers' allows to disable the automatic quoting
+ in the SQL queries of the DBQuery, MDB2, and PDO DataSource drivers
(thanks to Matt Rosenquist)
- Bug #13339: Automatic ORDER BY sort string addition can fail if subqueries
are used in the the DBQuery, MDB2, and PDO DataSource drivers
http://cvs.php.net/viewvc.cgi/pear/Structures_DataGrid/DataGrid/DataSource.php?r1=1.46&r2=1.47&diff_format=u
Index: pear/Structures_DataGrid/DataGrid/DataSource.php
diff -u pear/Structures_DataGrid/DataGrid/DataSource.php:1.46
pear/Structures_DataGrid/DataGrid/DataSource.php:1.47
--- pear/Structures_DataGrid/DataGrid/DataSource.php:1.46 Tue Apr 1 08:50:13 2008
+++ pear/Structures_DataGrid/DataGrid/DataSource.php Sun Apr 6 15:24:29 2008
@@ -35,9 +35,9 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * CVS file id: $Id: DataSource.php,v 1.46 2008/04/01 08:50:13 olivierg Exp $
+ * CVS file id: $Id: DataSource.php,v 1.47 2008/04/06 15:24:29 wiesemann Exp $
*
- * @version $Revision: 1.46 $
+ * @version $Revision: 1.47 $
* @package Structures_DataGrid
* @category Structures
* @license http://opensource.org/licenses/bsd-license.php
New BSD License
@@ -70,7 +70,7 @@
* @author Mark Wiesemann <wiesemann@php.net>
* @package Structures_DataGrid
* @category Structures
- * @version $Revision: 1.46 $
+ * @version $Revision: 1.47 $
*/
class Structures_DataGrid_DataSource
{
@@ -473,16 +473,12 @@
* - count_query: (string) Query that calculates the number of rows. See below
* for more information about when such a count query
* is needed.
- * - quote_identifiers: (bool) Whether identifiers should be quoted or not. If
- * you have field names in the form "table.field",
- * set this option to boolean false; otherwise the
- * automatic quoting might lead to syntax errors.
*
* @author Olivier Guilyardi <olivier@samalyse.com>
* @author Mark Wiesemann <wiesemann@php.net>
* @package Structures_DataGrid
* @category Structures
- * @version $Revision: 1.46 $
+ * @version $Revision: 1.47 $
*/
class Structures_DataGrid_DataSource_SQLQuery
extends Structures_DataGrid_DataSource
@@ -529,8 +525,7 @@
$this->_addDefaultOptions(array('dbc' => null,
'dsn' => null,
'db_options' => array(),
- 'count_query' => '',
- 'quote_identifiers' => true));
+ 'count_query' => ''));
$this->_setFeatures(array('multiSort' => true));
}
@@ -589,10 +584,9 @@
{
if (!empty($this->_sortSpec)) {
foreach ($this->_sortSpec as $field => $direction) {
- if ($this->_options['quote_identifiers'] === true) {
- $field = $this->_quoteIdentifier($field);
- }
- $sortArray[] = $field . ' ' . $direction;
+ $fields = preg_split('#\.#', $field);
+ $fields = array_map(array($this, '_quoteIdentifier'), $fields);
+ $sortArray[] = join('.', $fields) . ' ' . $direction;
}
$sortString = join(', ', $sortArray);
} else {
@@ -616,6 +610,10 @@
// yes => new ORDER BY statement needs to be appended
$appendOrderBy = true;
}
+ // if no ORDER BY statement exists, a new one needs to be appended
+ if ($orderByPos === false) {
+ $appendOrderBy = true;
+ }
if ($appendOrderBy === true) {
$query .= ' ORDER BY ' . $sortString;
} else {
@@ -732,7 +730,7 @@
* @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
* @link http://php.net/function.strripos
* @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.46 $
+ * @version $Revision: 1.47 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/