cvs: pear /MDB2/MDB2/Driver/Function Common.php mssql.php mysql.php mysqli.php oci8.php /MDB2/tests MDB2_function_testcase.php
| From: | Lukas Smith | Date: | Mon, 17 Oct 2005 08:17:51 +0000 |
| Subject: | cvs: pear /MDB2/MDB2/Driver/Function Common.php mssql.php mysql.php mysqli.php oci8.php /MDB2/tests MDB2_function_testcase.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35636@lists.php.net to get a copy of this message | ||
lsmith Mon Oct 17 04:17:51 2005 EDT
Modified files:
/pear/MDB2/MDB2/Driver/Function Common.php mssql.php mysql.php
mysqli.php oci8.php
/pear/MDB2/tests MDB2_function_testcase.php
Log:
- added concat()
http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/Function/Common.php?r1=1.2&r2=1.3&ty=u
Index: pear/MDB2/MDB2/Driver/Function/Common.php
diff -u pear/MDB2/MDB2/Driver/Function/Common.php:1.2 pear/MDB2/MDB2/Driver/Function/Common.php:1.3
--- pear/MDB2/MDB2/Driver/Function/Common.php:1.2 Mon Oct 17 04:05:48 2005
+++ pear/MDB2/MDB2/Driver/Function/Common.php Mon Oct 17 04:17:49 2005
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.2 2005/10/17 08:05:48 lsmith Exp $
+// $Id: Common.php,v 1.3 2005/10/17 08:17:49 lsmith Exp $
//
/**
@@ -66,7 +66,7 @@
/**
* return string for internal table used when calling only a function
*
- * @return string to call a function to get a substring
+ * @return string for internal table used when calling only a function
* @access public
**/
function functionTable()
@@ -115,6 +115,20 @@
}
return "SUBSTRING($value FROM $position)";
}
+
+ // }}}
+ // {{{ concat()
+
+ /**
+ * return string to caoncatenate two strings
+ *
+ * @return string to caoncatenate two strings
+ * @access public
+ **/
+ function concat($value1, $value2)
+ {
+ return "$value1 || $value2";
+ }
}
?>
\ No newline at end of file
http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/Function/mssql.php?r1=1.1&r2=1.2&ty=u
Index: pear/MDB2/MDB2/Driver/Function/mssql.php
diff -u pear/MDB2/MDB2/Driver/Function/mssql.php:1.1 pear/MDB2/MDB2/Driver/Function/mssql.php:1.2
--- pear/MDB2/MDB2/Driver/Function/mssql.php:1.1 Sun Oct 16 04:56:51 2005
+++ pear/MDB2/MDB2/Driver/Function/mssql.php Mon Oct 17 04:17:49 2005
@@ -42,7 +42,7 @@
// | Author: Frank M. Kromann <frank@kromann.info> |
// +----------------------------------------------------------------------+
//
-// $Id: mssql.php,v 1.1 2005/10/16 08:56:51 lsmith Exp $
+// $Id: mssql.php,v 1.2 2005/10/17 08:17:49 lsmith Exp $
//
require_once 'MDB2/Driver/Function/Common.php';
@@ -56,6 +56,19 @@
*/
class MDB2_Driver_Function_mssql extends MDB2_Driver_Function_Common
{
+ // }}}
+ // {{{ concat()
+
+ /**
+ * return string to caoncatenate two strings
+ *
+ * @return string to caoncatenate two strings
+ * @access public
+ **/
+ function concat($value1, $value2)
+ {
+ return "$value1 + $value2";
+ }
}
// }}}
?>
http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/Function/mysql.php?r1=1.1&r2=1.2&ty=u
Index: pear/MDB2/MDB2/Driver/Function/mysql.php
diff -u pear/MDB2/MDB2/Driver/Function/mysql.php:1.1 pear/MDB2/MDB2/Driver/Function/mysql.php:1.2
--- pear/MDB2/MDB2/Driver/Function/mysql.php:1.1 Sun Oct 16 04:56:51 2005
+++ pear/MDB2/MDB2/Driver/Function/mysql.php Mon Oct 17 04:17:49 2005
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
//
-// $Id: mysql.php,v 1.1 2005/10/16 08:56:51 lsmith Exp $
+// $Id: mysql.php,v 1.2 2005/10/17 08:17:49 lsmith Exp $
//
require_once 'MDB2/Driver/Function/Common.php';
@@ -56,5 +56,18 @@
*/
class MDB2_Driver_Function_mysql extends MDB2_Driver_Function_Common
{
+ // }}}
+ // {{{ concat()
+
+ /**
+ * return string to caoncatenate two strings
+ *
+ * @return string to caoncatenate two strings
+ * @access public
+ **/
+ function concat($value1, $value2)
+ {
+ return "CONCAT($value1, $value2)";
+ }
}
?>
\ No newline at end of file
http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/Function/mysqli.php?r1=1.1&r2=1.2&ty=u
Index: pear/MDB2/MDB2/Driver/Function/mysqli.php
diff -u pear/MDB2/MDB2/Driver/Function/mysqli.php:1.1 pear/MDB2/MDB2/Driver/Function/mysqli.php:1.2
--- pear/MDB2/MDB2/Driver/Function/mysqli.php:1.1 Sun Oct 16 04:56:51 2005
+++ pear/MDB2/MDB2/Driver/Function/mysqli.php Mon Oct 17 04:17:49 2005
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
//
-// $Id: mysqli.php,v 1.1 2005/10/16 08:56:51 lsmith Exp $
+// $Id: mysqli.php,v 1.2 2005/10/17 08:17:49 lsmith Exp $
//
require_once 'MDB2/Driver/Function/Common.php';
@@ -56,5 +56,18 @@
*/
class MDB2_Driver_Function_mysqli extends MDB2_Driver_Function_Common
{
+ // }}}
+ // {{{ concat()
+
+ /**
+ * return string to caoncatenate two strings
+ *
+ * @return string to caoncatenate two strings
+ * @access public
+ **/
+ function concat($value1, $value2)
+ {
+ return "CONCAT($value1, $value2)";
+ }
}
?>
\ No newline at end of file
http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/Function/oci8.php?r1=1.2&r2=1.3&ty=u
Index: pear/MDB2/MDB2/Driver/Function/oci8.php
diff -u pear/MDB2/MDB2/Driver/Function/oci8.php:1.2 pear/MDB2/MDB2/Driver/Function/oci8.php:1.3
--- pear/MDB2/MDB2/Driver/Function/oci8.php:1.2 Mon Oct 17 04:06:28 2005
+++ pear/MDB2/MDB2/Driver/Function/oci8.php Mon Oct 17 04:17:49 2005
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
-// $Id: oci8.php,v 1.2 2005/10/17 08:06:28 lsmith Exp $
+// $Id: oci8.php,v 1.3 2005/10/17 08:17:49 lsmith Exp $
require_once 'MDB2/Driver/Function/Common.php';
@@ -61,7 +61,7 @@
/**
* return string for internal table used when calling only a function
*
- * @return string to call a function to get a substring
+ * @return string for internal table used when calling only a function
* @access public
**/
function functionTable()
http://cvs.php.net/diff.php/pear/MDB2/tests/MDB2_function_testcase.php?r1=1.3&r2=1.4&ty=u
Index: pear/MDB2/tests/MDB2_function_testcase.php
diff -u pear/MDB2/tests/MDB2_function_testcase.php:1.3
pear/MDB2/tests/MDB2_function_testcase.php:1.4
--- pear/MDB2/tests/MDB2_function_testcase.php:1.3 Mon Oct 17 04:08:30 2005
+++ pear/MDB2/tests/MDB2_function_testcase.php Mon Oct 17 04:17:50 2005
@@ -41,7 +41,7 @@
// | Author: Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
-// $Id: MDB2_function_testcase.php,v 1.3 2005/10/17 08:08:30 lsmith Exp $
+// $Id: MDB2_function_testcase.php,v 1.4 2005/10/17 08:17:50 lsmith Exp $
class MDB2_Function_TestCase extends MDB2_TestCase
{
@@ -135,5 +135,25 @@
$this->assertEquals('1234', $result, 'Error: substrings not
equals');
}
}
+
+ /**
+ * Test concat()
+ */
+ function testConcat()
+ {
+ if (!$this->methodExists($this->db->function, 'concat')) {
+ return;
+ }
+
+ $functionTable_clause = $this->db->function->functionTable();
+ $concat_clause =
$this->db->function->concat($this->db->quote('time', 'text'),
$this->db->quote('stamp', 'text'));
+ $query = 'SELECT '.$concat_clause . $functionTable_clause;
+ $result = $this->db->queryOne($query);
+ if (PEAR::isError($result)) {
+ $this->assertFalse(true, 'Error getting substring');
+ } else {
+ $this->assertEquals('timestamp', $result, 'Error: could not
concatenate "timestamp"');
+ }
+ }
}
?>
\ No newline at end of file