sqlite 跨数据库查询

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;

}

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。