PHP Classes

File: test_del.php

Recommend this page to a friend!
  Classes of beiliwenxiao   SharedMemory   test_del.php   Download  
File: test_del.php
Role: Example script
Content type: text/plain
Description: Example
Class: SharedMemory
Cache content using eAccelerator extension
Author: By
Last change:
Date: 14 years ago
Size: 1,648 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
           
            //del test

       
}
   
        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_sync_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');
$user_A->delData();
$userinfo=$user_A->getData();
print_r($userinfo);
echo
"<br /><br /><br />";


?>