假设一个日志表Log 中有一个user属性用来保存关联的User表里的一条数据
require_once './vendor/leancloud-sdk/src/autoload.php';
Client::initialize($this->appid, $this->appkey, $this->masterkey);
Client::setDebug(false);
$logObject = new LeanObject("Log");
//user属性数据
$json = array(
"__type" => "Pointer",
"className" => "User",
"objectId" => "5f438c7c6e44e300089872be"//user表记录的objectId
);
$obj = Client::decode($json, null);
logObject ->set('user',$obj);
try{
$re = $logObject ->save();
}catch (CloudException $e){
echo $e->getMessage();
}