码迷,mamicode.com
首页 > 数据库 > 详细

sqlite 跨数据库查询

时间:2015-04-07 17:01:10      阅读:449      评论:0      收藏:0      [点我收藏+]

标签:

try {

$dbh = new PDO($dbrootemp, null, null);

$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);

$dbh->exec("attach database ‘/dat/paramconf.dat‘ as paramconf");

$sql = "select a.device_addr,a.mp_name,b.td_temperature,b.td_humidity from paramconf.t_modbus_param a, t_temp_data b where b.device_addr=a.device_addr and mp_enable=1";
// $sql = "select * from t_temp_data";

$sth = $dbh->query($sql);
$sth->setFetchMode(PDO::FETCH_ASSOC);

$resultHT = $sth->fetchAll();

$dbh->exec("detach database paramconf");

$dbh=null;
// print_r($resultHT);
}catch (PDOException $e)
{
echo ‘Connection failed: ‘ . $e->getMessage();
$sth = null;

}

sqlite 跨数据库查询

标签:

原文地址:http://www.cnblogs.com/hzijone/p/4398506.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!