cvs: pear /MDB_QueryTool/QueryTool Query.php
| From: | Lorenzo Alberton | Date: | Wed, 28 Apr 2004 18:51:57 +0000 |
| Subject: | cvs: pear /MDB_QueryTool/QueryTool Query.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-18897@lists.php.net to get a copy of this message | ||
quipo Wed Apr 28 14:51:57 2004 EDT
Modified files:
/pear/MDB_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/MDB_QueryTool/QueryTool/Query.php?r1=1.28&r2=1.29&ty=u
Index: pear/MDB_QueryTool/QueryTool/Query.php
diff -u pear/MDB_QueryTool/QueryTool/Query.php:1.28 pear/MDB_QueryTool/QueryTool/Query.php:1.29
--- pear/MDB_QueryTool/QueryTool/Query.php:1.28 Tue Apr 27 19:48:42 2004
+++ pear/MDB_QueryTool/QueryTool/Query.php Wed Apr 28 14:51:57 2004
@@ -15,7 +15,7 @@
// | Author: Lorenzo Alberton <l.alberton at quipo.it> |
// +----------------------------------------------------------------------+
//
-// $Id: Query.php,v 1.28 2004/04/27 23:48:42 quipo Exp $
+// $Id: Query.php,v 1.29 2004/04/28 18:51:57 quipo Exp $
//
// This is just a port of DB_QueryTool, originally written by
// Wolfram Kriesing and Paolo Panto, vision:produktion <wk@visionp.de>
@@ -105,12 +105,7 @@
* @var boolean if to use the MDB_QueryTool_Result as a result or not
* @access private
*/
- var $_useResult = false;
-
- /**
- * @var boolean if to use the MDB_QueryTool_Result_Object as a result or not
- */
- var $_useResultObject = false;
+ var $_resultType = 'none';
/**
* @var array the metadata temporary saved
@@ -131,7 +126,7 @@
var $_select = '*';
/**
- * @var string
+ * @var string the rows that shall not be selected
* @access private
*/
var $_dontSelect = '';
@@ -2064,27 +2059,26 @@
// {{{ returnResult()
/**
+ * Return the chosen result type
*
- * @param resultSet reference
- * @return MDB_QueryTool_Result if "useResult"==TRUE, the $result otherwise
- * @access public
+ * @param object reference
+ * @return mixed [boolean, array or object]
+ * @access public
*/
function returnResult(&$result)
{
- if ($this->_useResult) {
- if ($result === false) {
- return false;
- }
- return new MDB_QueryTool_Result($result);
+ if ($this->_resultType == 'none') {
+ return $result;
}
- if ($this->_useResultObject) {
- if ($result === false) {
- echo 'HERE';
- return false;
- }
- return new MDB_QueryTool_Result_Object($result);
+ if ($result === false) {
+ return false;
+ }
+ //what about allowing other (custom) result types?
+ switch (strtolower($this->_resultType)) {
+ case 'object': return new MDB_QueryTool_Result_Object($result);
+ case 'array':
+ default: return new MDB_QueryTool_Result($result);
}
- return $result;
}
// }}}
@@ -2180,36 +2174,35 @@
// {{{ useResult()
/**
+ * Choose the type of the returned result
*
- * @param boolean
+ * @param string $type ['array' | 'object' | 'none']
+ * For BC reasons, $type=true is equal to 'array',
+ * $type=false is equal to 'none'
* @access public
*/
- function useResult($doit=true)
+ function useResult($type='array')
{
- $this->_useResult = $doit;
- if ($doit) {
- require_once 'MDB/QueryTool/Result.php';
+ if ($type === true) {
+ $type = 'array';
+ } elseif ($type === false) {
+ $type = 'none';
+ }
+ switch (strtolower($type)) {
+ case 'array':
+ $this->_resultType = 'array';
+ require_once 'MDB/QueryTool/Result.php';
+ break;
+ case 'object':
+ $this->_resultType = 'object';
+ require_once 'MDB/QueryTool/Result/Object.php';
+ break;
+ default:
+ $this->_resultType = 'none';
}
}
// }}}
- // {{{ useResultObject()
-
- /**
- * If true, MDB_QueryTool will return objects instead of arrays
- *
- * @param boolean
- * @return
- */
- function useResultObject($doit=true)
- {
- $this->_useResultObject = $doit;
- if ($doit) {
- require_once 'MDB/QueryTool/Result/Object.php';
- }
- }
-
- // }}}
// {{{ setErrorCallback()
/**