cvs: pear /DB_DataObject DataObject.php

From: Date: Tue, 29 Jun 2004 09:42:14 +0000
Subject: cvs: pear /DB_DataObject DataObject.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-21240@lists.php.net to get a copy of this message
alan_k Tue Jun 29 05:42:14 2004 EDT Modified files: /pear/DB_DataObject DataObject.php Log: fix bug #1726 - enable orderby and limit to be used. http://cvs.php.net/diff.php/pear/DB_DataObject/DataObject.php?r1=1.265&r2=1.266&ty=u Index: pear/DB_DataObject/DataObject.php diff -u pear/DB_DataObject/DataObject.php:1.265 pear/DB_DataObject/DataObject.php:1.266 --- pear/DB_DataObject/DataObject.php:1.265 Fri Jun 18 05:11:47 2004 +++ pear/DB_DataObject/DataObject.php Tue Jun 29 05:42:13 2004 @@ -20,7 +20,7 @@ * @package DB_DataObject * @category DB * - * $Id: DataObject.php,v 1.265 2004/06/18 09:11:47 alan_k Exp $ + * $Id: DataObject.php,v 1.266 2004/06/29 09:42:13 alan_k Exp $ */ /* =========================================================================== @@ -1176,9 +1176,12 @@ * $object = new mytable(); * $object->ID=123; * echo $object->delete(); // builds a conditon + * * $object = new mytable(); * $object->whereAdd('age > 12'); - * $object->delete(true); // use the condition + * $object->limit(1); + * $object->orderBy('age DESC'); + * $object->delete(true); // dont use object vars, use the conditions, limit and order. * * @param bool $useWhere (optional) If DB_DATAOBJECT_WHEREADD_ONLY is passed in then * we will build the condition only using the whereAdd's. Default is to @@ -1195,6 +1198,8 @@ $DB = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]; $quoteIdentifiers = @$_DB_DATAOBJECT['CONFIG']['quote_identifiers']; + $extra_cond = " {$this->_query['order_by']} {$this->_query['limit']}"; + if (!$useWhere) { $keys = $this->keys(); @@ -1205,14 +1210,16 @@ if (!$this->_query['condition']) { $this->_build_condition($this->table(),array(),$keys); } - } + $extra_cond = ''; + } + // don't delete without a condition if (isset($this->_query) && $this->_query['condition']) { $table = ($quoteIdentifiers ? $DB->quoteIdentifier($this->__table) : $this->__table); - $r = $this->_query("DELETE FROM {$table} {$this->_query['condition']}"); + $r = $this->_query("DELETE FROM {$table} {$this->_query['condition']}{$extra_cond}"); if (PEAR::isError($r)) {

« previous php.pear.cvs (#21240) next »