HAS_ONE关联插入问题请大奖帮忙看看什么原因

浏览:529 发布日期:2014/03/25 分类:求助交流
UserRelationModel<?php
namespace Home\Model;
use Think\Model\RelationModel;
/**
 * 用户与用户信息表关联模型
 */
Class UserRelationModel extends RelationModel {

    //定义主表名称
    Protected $tableName = 'user';

    //定义用户与用户信处表关联关系属性
    Protected $_link = array(
        'userinfo' => array(
            'mapping_type'  => self::HAS_ONE,
            'class_name'    => 'userinfo',        
            'foreign_key'   => 'uid',
            )
        );


}
?>
表单处理$data = array(
            'account' => I('post.account'),
            'password' => I('post.pwd','', 'md5'),
            'registime' => $_SERVER['REQUEST_TIME'],
            'userinfo' => array(
                'username' => I('post.uname')
                )
            );
$User = D('UserRelation');
$id = $User->relation(true)->add($data);
echo D('UserRelation')->getLastSql();
sql输出
INSERT INTO `hd_user` (`account`,`password`,`registime`) VALUES ('est444','cc03e747a6afbbcbf8be7668acfebee5',1395734024)

麻烦看下哪里有问题
关联没有起作用是怎么回事啊
麻烦大家帮看一下 在此谢谢了
最佳答案
评论( 相关
后面还有条评论,点击查看>>