On 6/6/06 9:55 AM, Ruben Rubio Rey wrote:
Im having a trouble using memcached with pear db. When im using memcache to store and retrieve an string, all works fine. When Im using memcache to store a pear db resulset, it does not work!! This retrieves data but pear::db does not understand it. I really dont know
This is because $db->query returns a resource, which is a reference to the data and not the data itself.
For example, let's say you're using the MySQL driver for PEAR::DB, then when you call $db->query(), it uses mysql_query(). This function will return a resource. When you store the resource to the memcache server and then later retrieve it, it no longer maintains its reference to the data.
If you want to store the data to the cache, I suggest you use getAll() to retrieve an array of data and then store that to the memcache server:
$db->setFetchMode(DB_FETCHMODE_ASSOC); $data =& $db->getAll($sSQL); memcache_set($MEMCACHE_STR, MD5($sSQL), $data, 0, 10); Now, your result set is stored properly on the memcache server. -- Ben Ramsey http://benramsey.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php