cvs: pear /DB_QueryTool/QueryTool Query.php
| From: | Lorenzo Alberton | Date: | Wed, 28 Apr 2004 18:49:04 +0000 |
| Subject: | cvs: pear /DB_QueryTool/QueryTool Query.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-18896@lists.php.net to get a copy of this message | ||
quipo Wed Apr 28 14:49:04 2004 EDT
Modified files:
/pear/DB_QueryTool/QueryTool Query.php
Log:
- phpdoc fixes
- changed useResult() to accept a $type parameter;
allowed params:
* 'none' (== false)
* 'array' (== true)
* 'object'
- dropped useResultObject() introduced yesterday
http://cvs.php.net/diff.php/pear/DB_QueryTool/QueryTool/Query.php?r1=1.43&r2=1.44&ty=u
Index: pear/DB_QueryTool/QueryTool/Query.php
diff -u pear/DB_QueryTool/QueryTool/Query.php:1.43 pear/DB_QueryTool/QueryTool/Query.php:1.44
--- pear/DB_QueryTool/QueryTool/Query.php:1.43 Tue Apr 27 19:43:02 2004
+++ pear/DB_QueryTool/QueryTool/Query.php Wed Apr 28 14:49:03 2004
@@ -15,7 +15,7 @@
// | Author: Wolfram Kriesing, Paolo Panto, vision:produktion <wk@visionp.de>
// +----------------------------------------------------------------------+
//
-// $Id: Query.php,v 1.43 2004/04/27 23:43:02 quipo Exp $
+// $Id: Query.php,v 1.44 2004/04/28 18:49:03 quipo Exp $
//
require_once 'PEAR.php';
@@ -56,16 +56,19 @@
/**
* @var string the where condition
+ * @access private
*/
var $_where = '';
/**
- * var string the order condition
+ * @var string the order condition
+ * @access private
*/
var $_order = '';
/**
* @var string the having definition
+ * @access private
*/
var $_having = '';
@@ -74,46 +77,56 @@
* the key is the join type, for now we have 'default' and
'left'
* inside each key 'table' contains the table
* key 'where' contains the where clause for the join
+ * @access private
*/
var $_join = array();
/**
* @var string which column to index the result by
+ * @access private
*/
var $_index = null;
/**
* @var string the group-by clause
+ * @access private
*/
var $_group = '';
/**
* @var array the limit
+ * @access private
*/
var $_limit = array();
/**
- * @var boolean if to use the DB_QueryTool_Result as a result or not
+ * @var string type of result to return
+ * @access private
*/
- var $_useResult = false;
+ var $_resultType = 'none';
/**
- * @var boolean if to use the DB_QueryTool_Result_Object as a result or not
+ * @var array the metadata temporary saved
+ * @access private
*/
- var $_useResultObject = false;
+ var $_metadata = array();
/**
- * @var array the metadata temporary saved
+ * @var string
+ * @access private
*/
- var $_metadata = array();
-
var $_lastQuery = null;
/**
- * the rows that shall be selected
+ * @var string the rows that shall be selected
+ * @access private
*/
var $_select = '*';
+ /**
+ * @var string the rows that shall not be selected
+ * @access private
+ */
var $_dontSelect = '';
/**
@@ -2101,29 +2114,27 @@
// {{{ returnResult()
/**
+ * Return the chosen result type
*
- * @version 2002/07/11
+ * @version 2004/04/28
* @access public
- * @author Wolfram Kriesing <wk@visionp.de>
- * @param
- * @return
+ * @param object reference
+ * @return mixed
*/
function returnResult(&$result)
{
- if ($this->_useResult) {
- if ($result === false) {
- return false;
- }
- return new DB_QueryTool_Result($result);
+ if ($this->_resultType == 'none') {
+ return $result;
}
- if ($this->_useResultObject) {
- if ($result === false) {
- echo 'HERE';
- return false;
- }
- return new DB_QueryTool_Result_Object($result);
+ if ($result === false) {
+ return false;
+ }
+ //what about allowing other (custom) result types?
+ switch (strtolower($this->_resultType)) {
+ case 'object': return new DB_QueryTool_Result_Object($result);
+ case 'array':
+ default: return new DB_QueryTool_Result($result);
}
- return $result;
}
// }}}
@@ -2134,8 +2145,8 @@
* @version 2002/07/11
* @access public
* @author Wolfram Kriesing <wk@visionp.de>
- * @param
- * @return
+ * @param mixed
+ * @return mixed
*/
function &_makeIndexed(&$data)
{
@@ -2227,38 +2238,36 @@
// {{{ useResult()
/**
+ * Choose the type of the returned result
*
- * @version 2002/07/11
+ * @version 2004/04/28
* @access public
- * @author Wolfram Kriesing <wk@visionp.de>
- * @param
- * @return
+ * @param string $type ['array' | 'object' | 'none']
+ * For BC reasons, $type=true is equal to 'array',
+ * $type=false is equal to 'none'
*/
- function useResult($doit=true)
+ function useResult($type='array')
{
- $this->_useResult = $doit;
- if ($doit) {
- require_once 'DB/QueryTool/Result.php';
+ if ($type === true) {
+ $type = 'array';
+ } elseif ($type === false) {
+ $type = 'none';
+ }
+ switch (strtolower($type)) {
+ case 'array':
+ $this->_resultType = 'array';
+ require_once 'DB/QueryTool/Result.php';
+ break;
+ case 'object':
+ $this->_resultType = 'object';
+ require_once 'DB/QueryTool/Result/Object.php';
+ break;
+ default:
+ $this->_resultType = 'none';
}
}
// }}}
- // {{{ useResultObject()
-
- /**
- * @author Roman Dostovalov <roman.dostovalov@ctco.lv>
- * @param boolean
- * @access public
- */
- function useResultObject($doit=true)
- {
- $this->_useResultObject = $doit;
- if ($doit) {
- require_once 'DB/QueryTool/Result/Object.php';
- }
- }
-
- // }}}
// {{{ setErrorCallback()
/**