使用thinkphp 关联模型has_one插入数据问题:插入数据的时候只操作一张表为什么?

浏览:1617 发布日期:2015/04/16 分类:求助交流 关键字: HAS_ONE关联模型 插入操作
使用thinkphp 关联模型has_one插入数据问题:插入数据的时候只操作一张表?
附加表关联主表的外键是 sid;具体内容
主表

附加表

代码如下:
1.sellerModel.class.php<?php
class sellerModel extends RelationModel{
    protected $_validate = array(
        array('username', 'require', '{%username_require}'), //不能为空
        array('username', '1,20', '{%username_length_error}', 0, 'length', 1), //用户名长度
        array('password', '6,20', '{%password_length_error}', 0, 'length', 1), //密码长度
    );
    protected $_link=array(
       'seller_other'=> array(
           'mapping_type'=>HAS_ONE,
           //'class_name'=>'seller_other',
           //'mapping_name'=>'sother',
           //外键
           'foreign_key'=>'id',
           'condition'=>'sid'
           ),
   );
}
?>
2.sellerAction.class.php 文件<?php
class sellerAction extends Action{
    public function add(){
        if($this->isPost()){
            $res = $this->_mod->relation(true)->add($_POST);
            var_dump($res);
        }
        $this->display();
    }
}
?>
调试最终执行的sql语句是 只操作seller一张数据表,而附加表没有插入数据呢?
最佳答案
评论() 相关
后面还有条评论,点击查看>>