cvs: pear /MDB2/MDB2/Driver/Function Common.php
| From: | Lukas Smith | Date: | Mon, 17 Oct 2005 08:05:49 +0000 |
| Subject: | cvs: pear /MDB2/MDB2/Driver/Function Common.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35630@lists.php.net to get a copy of this message | ||
lsmith Mon Oct 17 04:05:49 2005 EDT
Modified files:
/pear/MDB2/MDB2/Driver/Function Common.php
Log:
- added functionTable()
- use ibase implementation of now() and allow selection of timestamp, date or time
http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/Function/Common.php?r1=1.1&r2=1.2&ty=u
Index: pear/MDB2/MDB2/Driver/Function/Common.php
diff -u pear/MDB2/MDB2/Driver/Function/Common.php:1.1 pear/MDB2/MDB2/Driver/Function/Common.php:1.2
--- pear/MDB2/MDB2/Driver/Function/Common.php:1.1 Sun Oct 16 04:56:51 2005
+++ pear/MDB2/MDB2/Driver/Function/Common.php Mon Oct 17 04:05:48 2005
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.1 2005/10/16 08:56:51 lsmith Exp $
+// $Id: Common.php,v 1.2 2005/10/17 08:05:48 lsmith Exp $
//
/**
@@ -60,19 +60,46 @@
*/
class MDB2_Driver_Function_Common extends MDB2_Module_Common
{
- // {{{ now()
+ // }}}
+ // {{{ functionTable()
/**
- * return string to call a function to get the current timestamp inside an SQL statement
+ * return string for internal table used when calling only a function
*
- * @return string to call a function to get the current timestamp
+ * @return string to call a function to get a substring
* @access public
**/
- function now()
+ function functionTable()
{
- return "NOW()";
+ return '';
+ }
+
+ // {{{ now()
+
+ /**
+ * Return string to call a variable with the current timestamp inside an SQL statement
+ * There are three special variables for current date and time:
+ * - CURRENT_TIMESTAMP (date and time, TIMESTAMP type)
+ * - CURRENT_DATE (date, DATE type)
+ * - CURRENT_TIME (time, TIME type)
+ *
+ * @return string to call a variable with the current timestamp
+ * @access public
+ */
+ function now($type = 'timestamp')
+ {
+ switch ($type) {
+ case 'time':
+ return 'CURRENT_TIME';
+ case 'date':
+ return 'CURRENT_DATE';
+ case 'timestamp':
+ default:
+ return 'CURRENT_TIMESTAMP';
+ }
}
+ // }}}
// {{{ substring()
/**