关联查询,查询条件,不能起作用

浏览:871 发布日期:2014/08/01 分类:求助交流 关键字: 关联查询 外键 查询条件 关联操作 关联条件
Model代码<?php
namespace Student\Model;
use Think\Model\RelationModel;
class StudenttransferModel extends RelationModel{
    protected  $_link = array(
        'Studentget'=>array(
             'mapping_type'      => self::HAS_ONE,
            'class_name'=>'studentget',
            'mapping_name'=>'studentget',
            'foreign_key'=> 'stuid',//外键是stuid

            ),
        );


    
}

?>
namespace Student\Controller;
use Think\Controller;
class StuTransferController extends Controller {

    public function index(){
        $User=D('Studenttransfer') ;
        $condition['stuid']='222';
         $list=$User->relation(true)->where($condition)->find();
         print_r($list);
 
    }
我的查询条件不生效为何?生成的sql如下表前缀tb没有下划线

最佳答案
评论( 相关
后面还有条评论,点击查看>>