标签:tle ace mil 笔记 实体 任务 通过 nts query
定义:在客户端与实体之间建立一个代理对象(proxy),客户端对实体进行操作全部委派给代理对象,隐藏实体的具体实现细节$proxy = new \IMooc\Proxy();
$proxy->getUserName($id);
$proxy->setUserName($id, $name);
<?php
namespace IMooc;
interface IUserProxy
{
function getUserName($id);
function setUserName($id, $name);
}<?php
namespace IMooc;
class Proxy implements IUserProxy
{
function getUserName($id)
{
$db = Factory::createDatabase(‘slave‘);
$db->query("select name from user where id = $id limit 1");
}
function setUserName($id, $name)
{
$db = Factory::createDatabase(‘master‘);
$db->query("update user set name = $name where id = $id limit 1");
}
}
标签:tle ace mil 笔记 实体 任务 通过 nts query
原文地址:http://www.cnblogs.com/phonecom/p/a98dfd92bc0580b3141d14a2b04716cc.html