PHP Classes

File: test_show.php

Recommend this page to a friend!
  Packages of beiliwenxiao   SharedMemory   test_show.php   Download  
File: test_show.php
Role: Example script
Content type: text/plain
Description: Example
Class: SharedMemory
Cache content using eAccelerator extension
Author: By
Last change:
Date: 17 years ago
Size: 1,626 bytes
 

Contents

Class file image Download
<?php
header("Cache-Control: no-cache, must-revalidate");     
header("Pragma: no-cache"); 
session_cache_limiter('no-cache');
/*
*example class
*/

class UserInfo
{
    
    var $userinfo;
    
    function getUserInfo($id)
    {
        if ($id==0 or id=='')
        {
            return '';
        }

        $userinfo = eaccelerator_get('UserInfo_getUserInfo_'.$id);
        
        if (!$userinfo)
        {
            //you database code like: select * from user where id=$id
            
            //if you use database.you can del this
        
        }
    
        return $userinfo;
    }

    function  getUserInfo_updata($id,$data)
    {
        if ($id<>0 and $id<>'')
        {
        //check db 
        //if it have this id then updata ,else insert
        //like this: updata user set hp=$data['hp'] where id = $id
        //here just easy example
        //if you use database.you can del this
        echo "<br /><br />call UserInfo::getUserInfo_updata()<br />";
        echo "<br /><br />id:".$id."<br />";
        echo "data:";
        print_r($data);
        echo "<br />";
        }
    }

    function  getUserInfo_del($id)
    {
        if ($id<>0 and $id<>'')
        {
        //check db 
        //if it have this id then updata ,else insert
        //like this:delete user where id = $id
        //here just easy example
        //if you use database.you can del this
        echo "<br />call UserInfo::getUserInfo_del()<br />";
        echo "<br /><br />id:".$id."<br />";
        }
    }

}


require_once 'SharedMemory.class.php';

/*
*example how to use
*
*You can set regular implementation of the syncData();
*/

echo "<font color=red>get userinfo:</font><br />";
$user_A=new SharedMemory('UserInfo','GetUserInfo','1');
$userinfo=$user_A->getData();
print_r($userinfo);



?>