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 replace into操作
参考链接:http://www.trinea.cn/android/sqlite-insert-or-update/
1、数据库表增加索引
2、replace 本质是插入操作,在replace后,自动递增的id总是被+1