Resources cannot be stored from script to script.
PHP cleans them up and nukes their contents at script end.
This is what all the "frameworks" folks are trying to "fix"...
:-) :-) :-)
On Tue, June 6, 2006 8:55 am, Ruben Rubio Rey wrote:
> Hi,
>
> 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
>
> Any ideas?
> Thanks in advance
>
> Code:
>
> $sql = "SELECT * FROM anytable";
> $myownqry= cachedSQL($sql);
>
> while ($rs_qryPhoto =& $myownqry->fetchRow()) {
> echo "OK<bR>"; //When variable is taken from cache, nothink is
> shown!!!
> }
>
>
> $MEMCACHE_CONNECTED=0;
> $MEMCACHE_STR="";
> function memcachedConnect(){
>
> global $MEMCACHE_CONNECTED,$MEMCACHE_STR;
>
> if(!($MEMCACHE_CONNECTED)){
> $MEMCACHE_CONNECTED=1;
> $MEMCACHE_STR = memcache_connect('192.168.2.8', 11211);
> }
>
> }
>
> function cachedSQL($sSQL) {
> global $db,$MEMCACHE_CONNECTED,$MEMCACHE_STR;
> memcachedConnect();
>
> if($tmp=memcache_get($MEMCACHE_STR,MD5($sSQL))){
> echo "Cached<br>";
> //echo var_dump($tmp);
> }else{
> $tmp = $db->query($sSQL);
> //echo var_dump($tmp);
> echo "<b>NOT</b> Cached<br>";
> memcache_set($MEMCACHE_STR, MD5($sSQL), $tmp, 0, 10);
>
> }
> echo "<br><br>";
> return $tmp;
>
> }
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php