附加表关联主表的外键是 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一张数据表,而附加表没有插入数据呢?
最佳答案