class sqlitedb {
//打开sqlite数据库
function conn($dbname) {
$conn = null;
$path ="/etc/ypm/system.cfg";
if(file_exists($path)){
$dbname = str_replace('../', '', $dbname);
$dbname = str_replace('./', '', $dbname);
require_once('pqmdconfig.php');
$key = "dbpath";//verpath
$dbname = getconfig($key,$path).$dbname;
}
$dbpath = 'sqlite:'.$dbname;
try {
$conn = new pdo($dbpath);
//$conn->begintransaction();
} catch(pdoexception $e) {
echo 'exception is:'.$e->getmessage();
}
return $conn;
}
以上是数据库的链接和查询操作
include "shm_offset.php";
include "sqlite.php";
$obj= new sqlitedb();
if ( isset($_get['page'])) {//翻页处理
if($conn=$obj->conn('../ypm.db')){
$sql = "select max(id) as total from data_3sec ";
$total = $obj->query($conn,$sql);
$total = $total['0']['total'];
$now=$_get['page']?$_get['page']:1;
if($now >=$total){$now = $total;}
if($now $list = $now;
$argv = $_get['argv'];
$argv = explode("|",$argv);
$num = count($argv)-1;
//$sql = "select data,time from data_3sec order by id desc limit ".$list.",1";
$sql = "select data,time,id from data_3sec order by time desc limit 1 offset ".($list-1);
//因为数据量庞大,无法计算总数(卡死),所以改成id
//dump($sql);
// exit();
$result = $obj->query($conn,$sql);
$data=$result[0]['data'];
// dump($data);
以上是部分查询代码 call to a member function execute() on a non-obje 之前是两个数据库是可以运行的,现在改成了一个数据库之后就报这个错误,代码数据库名字方面也该多来了求助各位高手
错误信息指出 Execute 方法不存在,但在你的代码中并未看到在哪里调用了 Execute
错误信息指出 Execute 方法不存在,但在你的代码中并未看到在哪里调用了 Execute
print_r($conn);
$sth = $conn->prepare($sql);
print_r($sth);
print_r($conn);
$sth = $conn->prepare($sql);
print_r($sth);
print_r($conn);
$sth = $conn->prepare($sql);
print_r($sth);
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号