cvs: pear /DB_QueryTool/QueryTool Query.php
| From: | Wolfram Kriesing | Date: | Tue, 23 Sep 2003 11:28:13 +0000 |
| Subject: | cvs: pear /DB_QueryTool/QueryTool Query.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-13006@lists.php.net to get a copy of this message | ||
cain Tue Sep 23 07:28:13 2003 EDT
Modified files:
/pear/DB_QueryTool/QueryTool Query.php
Log:
+ added getQueryString() and setDbInstance()
Index: pear/DB_QueryTool/QueryTool/Query.php
diff -u pear/DB_QueryTool/QueryTool/Query.php:1.32 pear/DB_QueryTool/QueryTool/Query.php:1.33
--- pear/DB_QueryTool/QueryTool/Query.php:1.32 Mon Sep 15 11:04:05 2003
+++ pear/DB_QueryTool/QueryTool/Query.php Tue Sep 23 07:28:13 2003
@@ -15,7 +15,7 @@
// | Author: Wolfram Kriesing, Paolo Panto, vision:produktion <wk@visionp.de>
// +----------------------------------------------------------------------+
//
-// $Id: Query.php,v 1.32 2003/09/15 15:04:05 cain Exp $
+// $Id: Query.php,v 1.33 2003/09/23 11:28:13 cain Exp $
//
require_once 'PEAR.php';
@@ -172,7 +172,7 @@
* @author Wolfram Kriesing <wk@visionp.de>
* @param object db-object
*/
- function __construct( $dsn , $options=array() )
+ function __construct( $dsn=false , $options=array() )
{
if (!isset($options['autoConnect'])) {
$autoConnect = true;
@@ -187,7 +187,7 @@
$this->setErrorLogCallback($options['errorLogCallback']);
}
- if ($autoConnect) {
+ if ($autoConnect && $dsn) {
$this->connect($dsn);
}
/* we would need to parse the dsn first ... i dont feel like now :-)
@@ -226,7 +226,7 @@
* @author Wolfram Kriesing <wk@visionp.de>
* @param object db-object
*/
- function DB_QueryTool_Query( $dsn , $options=array() )
+ function DB_QueryTool_Query( $dsn=false , $options=array() )
{
$this->__construct( $dsn , $options );
}
@@ -237,6 +237,20 @@
}
/**
+ * Setup using an existing connection.
+ * this also sets the DB_FETCHMODE_ASSOC since this class
+ * needs this to be set!
+ *
+ * @param object a reference to an existing DB-object
+ * @return void
+ */
+ function setDbInstance( &$dbh)
+ {
+ $this->db =& $dbh;
+ $this->db->setFetchMode(DB_FETCHMODE_ASSOC);
+ }
+
+ /**
* get the data of a single entry
* if the second parameter is only one column the result will be returned
* directly not as an array!
@@ -420,6 +434,16 @@
{
$this->getDefaultValues();
}
+
+ /**
+ * Render the current query and return it as a string.
+ *
+ * @return string the current query
+ */
+ function getQueryString()
+ {
+ return $this->_buildSelectQuery();
+ }
/**
* save data, calls either update or add