thinkphp 数据库设置前缀问题 联合查询

1.数据库设置前缀问题

Home/Conf下的config.php

return array(
    //'配置项'=>'配置值'
    'DB_TYPE'=>'mysql',
    'DB_HOST'=>'1.2.3.4',
    'DB_NAME'=>'3s',
    'DB_USER'=>'root',
    'DB_PWD'=>'password',
    'DB_PORT'=>'3306',
    'DB_PREFIX'=>'tp_',  //设置表前缀
);
?>

问题
不管表前缀设置成什么,运行的时候始终默认表前缀为think_
暂时解决方案

$t = M('datasheet',null);//第二个null是表前缀,设置为空就行了

2.联合查询

 $Model = new Model();
 $sql = ('select a.id,a.brand from qy_phone_brand as a where a.id in  
     (select distinct b.phone_brand_id from qy_phone_emotion as b)');

  $voList = $Model->query($sql);
  var_dump($voList);

你可能感兴趣的:(thinkphp)