uw Fri Mar 2 06:10:29 2001 EDT Modified files: /php4/pear/Cache/Container phplib.php Log: Fixed: MySQL data, expire, garbageCollection - forgot to mention for db.php and this file changed suggested SQL column type for content (data) from text to mediumtext Index: php4/pear/Cache/Container/phplib.php diff -u php4/pear/Cache/Container/phplib.php:1.2 php4/pear/Cache/Container/phplib.php:1.3 --- php4/pear/Cache/Container/phplib.php:1.2 Thu Mar 1 09:18:23 2001 +++ php4/pear/Cache/Container/phplib.php Fri Mar 2 06:10:29 2001 @@ -16,14 +16,14 @@ // | Sebastian Bergmann <[EMAIL PROTECTED]> | // +----------------------------------------------------------------------+ // -// $Id: phplib.php,v 1.2 2001/03/01 17:18:23 sbergmann Exp $ +// $Id: phplib.php,v 1.3 2001/03/02 14:10:29 uw Exp $ require_once 'Cache/Container.php'; /* CREATE TABLE cache ( id CHAR(32) NOT NULL DEFAULT '', - data TEXT NOT NULL DEFAULT '', + content MEDIUMTEXT NOT NULL DEFAULT '', expires INT(9) NOT NULL DEFAULT 0, changed TIMESTAMP(14), @@ -37,7 +37,7 @@ * Stores cache data into a database table. * * @author Ulf Wendel <[EMAIL PROTECTED]>, Sebastian Bergmann <[EMAIL PROTECTED]> -* @version $Id: phplib.php,v 1.2 2001/03/01 17:18:23 sbergmann Exp $ +* @version $Id: phplib.php,v 1.3 2001/03/02 14:10:29 uw Exp $ * @package Cache */ class Cache_Container_phplib extends Cache_Container { @@ -79,11 +79,11 @@ /** * Include path for you local.inc * - * HINT: If your're not using prepend.php you must + * HINT: If your're not using PHPLib's prepend.php you must * take care that all classes (files) references by you * local.inc are included automatically. So you might * want to write a new local2.inc that only referrs to - * the database class (file) you're using and includes all required files! + * the database class (file) you're using and includes all required files. * * @var string path to your local.inc - make sure to add a trailing slash * @see $local_file @@ -92,9 +92,20 @@ /** + * Creates an instance of a phplib db class to use it for storage. * - * @param mixed - */ + * @param mixed If empty the object tries to used the + * preconfigured class variables. If given it + * must be an array with: + * db_class => name of the DB class to use + * optional: + * db_file => filename of the DB class + * db_path => path to the DB class + * local_file => kind of local.inc + * local_patk => path to the local.inc + * see $local_path for some hints.s + * @see $local_path + */ function Cache_Container_phplib($options = "") { if (is_array($options)) @@ -103,8 +114,9 @@ if (!$this->db_class) return new CacheError("No database class specified.", __FILE__, __LINE__); - // include the required files - include_once($this->local_path . $this->local_file); + // include the required files + if ($this->local_file) + include_once($this->local_path . $this->local_file); // create a db object $this->db = new $this->db_class; @@ -114,7 +126,7 @@ function fetch($id) { - $query = sprintf("SELECT expires, data FROM %s WHERE id = '%s'", + $query = sprintf("SELECT expires, content FROM %s WHERE id = '%s'", $this->cache_table, $id ); @@ -122,7 +134,7 @@ if (!$this->db->Next_Record()) return array(NULL, NULL); - return array($this->db->f("expires"), $this->decode($this->db->f("data"))); + return array($this->db->f("expires"), $this->decode($this->db->f("content"))); } // end func fetch @@ -130,15 +142,15 @@ $this->flushPreload($id); - $query = sprintf("REPLACE INTO %s (data, expires, id) VALUES ('%s', %d, '%s')", + $query = sprintf("REPLACE INTO %s (content, expires, id) VALUES ('%s', %d, +'%s')", $this->cache_table, $this->encode($data), - $expires, + ($expires) ? $expires + time() : 0, $id ); - $this->db->query($query); + $this->db->query($query); - return (boolean)$this->db->affected_rows(); + return (boolean)$this->db->affected_rows(); } // end func save @@ -152,7 +164,7 @@ ); $this->db->query($query); - return (boolean)$this->db->affected_rows(); + return (boolean)$this->db->affected_rows(); } // end func delete @@ -163,7 +175,7 @@ $query = sprintf("DELETE FROM %s", $this->cache_table); $this->db->query($query); - return $this->db->affected_rows(); + return $this->db->affected_rows(); } // end func flush @@ -185,9 +197,9 @@ $this->cache_table, time() ); - #$this->db->query($query); + $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]