这是定义的关联模型
protected $_li
'User'=>array(
'mapping_type' =>BELONGS_TO,
'class_name' =>'User',
'foreign_key'=>'RUID',
'mapping_name'=>'User',
'mapping_fields'=>'UClass,UName,UHead',
'as_fields'=>'UClass,UName,UHead',
// 定义更多的关联属性
),
'List'=>array(
'mapping_type' =>BELONGS_TO,
'class_name' =>'List',
'foreign_key'=>'RTID',
'mapping_name'=>'List',
'mapping_fields'=>'TLastReplyUseID,TLastReplayTime',
'as_fields'=>'TLastReplyUseID,TLastReplayTime',
// 定义更多的关联属性
),
这是插入操作
$reply->RContents = $_POST['editorValue'];
$reply->RUID = session('uid');
$reply->RTID = $TID;
$time["List"] = array(
'TLastReplyUseID' =>session('uid'),
'TLastReplyTime' =>date("Y-m-d H:i:s"),
);
//$reply->relation(true)->save($time);
$result = $reply->relation(true)->save($time);
//将文章写入数据库
if($reply->relation(true)->add()){
$this->success('文章添加成功,返回上级页面');
}else{
$this->error('文章添加失败,返回上级页面');
}
4.png
( 147 KB 下载:7 次 )
最佳答案