[Vtigercrm-developers] [PATCH] PearDatabase: some new methods
Enrico Weigelt
weigelt at metux.de
Wed Sep 26 05:29:38 PDT 2007
Hi folks,
this patch adds the methods run_query_field() and sql_concat()
to the PearDatabase class ($adb variable), as already discussed
It fits against 5.1 and 5.1_jens.
cu
--
----------------------------------------------------------------------
Enrico Weigelt, metux IT service -- http://www.metux.de/
cellphone: +49 174 7066481 email: info at metux.de skype: nekrad666
----------------------------------------------------------------------
Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme
----------------------------------------------------------------------
-------------- next part --------------
diff -ruN htdocs.orig/include/database/PearDatabase.php htdocs/include/database/PearDatabase.php
--- htdocs.orig/include/database/PearDatabase.php 2007-05-11 02:17:06.000000000 +0200
+++ htdocs/include/database/PearDatabase.php 2007-05-11 02:55:29.000000000 +0200
@@ -434,6 +434,31 @@
return $this->change_key_case($result->FetchRow());
}
+ function sql_concat($list)
+ {
+ switch ($this->dbType)
+ {
+ case 'mysql':
+ return 'concat('.implode(',',$list).')';
+ case 'pgsql':
+ return '('.implode('||',$list).')';
+ default:
+ throw new Exception("unsupported dbtype \"".$this->dbType."\"");
+ }
+ }
+
+ function run_query_field($sql)
+ {
+ $this->checkConnection();
+ $result = $this->database->Execute($sql);
+
+ if (!is_object($result))
+ throw new Exception("query failed: $sql");
+
+ $row = $result->FetchRow();
+ return array_shift($row);
+ }
+
/* ADODB newly added. replacement for mysql_result() */
function query_result(&$result, $row, $col=0)
{
More information about the vtigercrm-developers
mailing list