From 43fa235da354c8b53aa69ba745c1d398a758fcaf Mon Sep 17 00:00:00 2001
From: svncommit <devs@roundcube.net>
Date: Wed, 26 Oct 2005 05:42:19 -0400
Subject: [PATCH] 

---
 program/include/rcube_mdb2.inc |   56 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/program/include/rcube_mdb2.inc b/program/include/rcube_mdb2.inc
index 7473fa3..a61f0b8 100755
--- a/program/include/rcube_mdb2.inc
+++ b/program/include/rcube_mdb2.inc
@@ -101,9 +101,27 @@
         $this->db_connected = true;
     }
 
-    // Query database (read operations)
+    // Query database
     
-    function query($query)
+    function query()
+    {
+		$params = func_get_args();
+		$query = array_shift($params);
+		
+		return $this->_query($query, 0, 0, $params);
+    }
+   
+	function limitquery()
+    {
+		$params = func_get_args();
+		$query = array_shift($params);
+		$offset = array_shift($params);
+		$numrows = array_shift($params);
+		
+		return $this->_query($query, $offset, $numrows, $params);
+    }
+    
+    function _query($query, $offset, $numrows, $params)
     {
         // Read or write ?
         if (strtolower(trim(substr($query,0,6)))=='select')
@@ -116,6 +134,9 @@
         if ($this->db_provider == 'sqlite')
             $query = $this->_sqlite_prepare_query($query);
             
+        $this->db_handle->row_offset = $offset;
+		$this->db_handle->row_limit = $numrows;
+		
         $result = $this->db_handle->query($query);
         
         if (PEAR::isError($result))
@@ -128,17 +149,6 @@
         return $this->_add_result($result, $query);
     }
 
-    function db_execute ($query)
-    {
-        $this->db_connect('w');
-
-        if ($this->db_provider == 'sqlite')
-            $query = $this->_sqlite_prepare_query($query);
-
-        $result = $this->db_handle->query($query);
-
-    }
-    
     function num_rows($res_id=NULL)
     {
         if (!$this->db_handle)
@@ -183,6 +193,26 @@
         return $result->fetchRow(MDB2_FETCHMODE_ASSOC);
     }
 
+	function quoteIdentifier ( $str )
+	{
+		if (!$this->db_handle)
+			$this->db_connect('r');
+			
+		return $this->db_handle->quoteIdentifier($str);
+	}
+	
+	function unixtimestamp($field)
+	{
+		switch($this->db_provider)
+			{
+			case 'pgsql':
+				return "EXTRACT (EPOCH FROM $field)";
+				break;
+			default:
+				return "UNIX_TIMESTAMP($field)";
+			}
+	}
+	
     function _add_result($res, $query)
     {
         // sql error occured

--
Gitblit v1.9.1