uw              Sat Mar  3 03:46:19 2001 EDT

  Modified files:              
    /php4/pear/Cache/Container  phplib.php 
  Log:
  bugfix: idExists(), inline Doc changes: class doc
  
  
Index: php4/pear/Cache/Container/phplib.php
diff -u php4/pear/Cache/Container/phplib.php:1.4 
php4/pear/Cache/Container/phplib.php:1.5
--- php4/pear/Cache/Container/phplib.php:1.4    Fri Mar  2 06:16:38 2001
+++ php4/pear/Cache/Container/phplib.php        Sat Mar  3 03:46:19 2001
@@ -16,29 +16,42 @@
 // |          Sebastian Bergmann <[EMAIL PROTECTED]>               |
 // +----------------------------------------------------------------------+
 //
-// $Id: phplib.php,v 1.4 2001/03/02 14:16:38 uw Exp $
+// $Id: phplib.php,v 1.5 2001/03/03 11:46:19 uw Exp $
 
-require_once 'Cache/Container.php';
+require_once '/Cache/Container.php';
 
-/*
-CREATE TABLE cache (
-  id       CHAR(32) NOT NULL DEFAULT '',
-  content  MEDIUMTEXT NOT NULL DEFAULT '',
-  expires  INT(9) NOT NULL DEFAULT 0,
-  
-  changed  TIMESTAMP(14),
-  
-  INDEX (expires),
-  PRIMARY KEY (id)
-)
-*/
-
 /**
 * Stores cache data into a database table.
+*
+* WARNING: Other systems might or might not support certain datatypes of 
+* the tables shown. As far as I know there's no large binary 
+* type in SQL-92 or SQL-99. Postgres seems to lack any 
+* BLOB or TEXT type, for MS-SQL you could use IMAGE, don't know 
+* about other databases. Please add sugestions for other databases to 
+* the inline docs.
+*
+* The field 'changed' has no meaning for the Cache itself. It's just there 
+* because it's a good idea to have an automatically updated timestamp
+* field for debugging in all of your tables.
+*
+* For _MySQL_ you need this DB table:
+*
+* CREATE TABLE cache (
+*   id        CHAR(32) NOT NULL DEFAULT '',
+*   content   BLOB NOT NULL DEFAULT '',
+*   expires   INT(9) NOT NULL DEFAULT 0,
+*  
+*   changed   TIMSTAMP(14) NOT NULL,
+*  
+*   INDEX (expires),
+*   PRIMARY KEY (id)
+* )
+*
 * 
 * @author   Ulf Wendel  <[EMAIL PROTECTED]>, Sebastian Bergmann 
<[EMAIL PROTECTED]>
-* @version  $Id: phplib.php,v 1.4 2001/03/02 14:16:38 uw Exp $
+* @version  $Id: phplib.php,v 1.5 2001/03/03 11:46:19 uw Exp $
 * @package  Cache
+* @see      save()
 */
 class Cache_Container_phplib extends Cache_Container {
   
@@ -115,10 +128,13 @@
             return new CacheError("No database class specified.", __FILE__, __LINE__);
 
         // include the required files
+        if ($this->db_file)
+            include_once($this->db_path . $this->db_file);
+            
         if ($this->local_file)
             include_once($this->local_path . $this->local_file);
-
-        // create a db object                
+            
+        // create a db object 
         $this->db = new $this->db_class;
 
     } // end constructor
@@ -164,12 +180,12 @@
     function delete($id) {
         
         $this->flushPreload($id);
-
-        $query = sprintf("DELETE FROM %s WHERE id = '%s'",
+        $this->db->query(
+                        sprintf("DELETE FROM %s WHERE id = '%s'",
                             $this->cache_table,
                             $id
-                          );
-        $this->db->query($query);
+                          )
+                    );
         
         return (boolean)$this->db->affected_rows();
     } // end func delete
@@ -178,9 +194,7 @@
     function flush() {
         
         $this->flushPreload();
-
-        $query = sprintf("DELETE FROM %s", $this->cache_table);
-        $this->db->query($query);
+        $this->db->query(sprintf("DELETE FROM %s", $this->cache_table));
 
         return $this->db->affected_rows();
     } // end func flush
@@ -188,11 +202,14 @@
     
     function idExists($id) {
         
-        $query = sprintf("SELECT id FROM %s WHERE ID = '%s'", 
+        $this->db->query(
+                        sprintf("SELECT id FROM %s WHERE ID = '%s'", 
                             $this->cache_table,
                             $id
-                         );
-        
+                        )   
+                    );
+                            
+        return $this->db->nf();                         
     } // end func isExists
     
     
@@ -200,11 +217,12 @@
         
         $this->flushPreload();
 
-        $query = sprintf("DELETE FORM %s WHERE expires <= %d AND expires > 0", 
+        $this->db->query( 
+                        sprintf("DELETE FORM %s WHERE expires <= %d AND expires > 0", 
                             $this->cache_table, 
                             time()
-                         );
-        $this->db->query($query);
+                        )
+                    );
                                  
     } // end func garbageCollection
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to