php - sqlite3 替换 sqlite_has_more

标签 php sqlite

首先感谢您的帮助。

代码段“while (sqlite_has_more($dres))”正在使用sqlite2,我需要sqlite3。如果没有 has_more 的替代品,是否还有另一个代码可以用来仍然查找是否有更多行可用?

仅供引用服务器更新了他们的内容,其中包括他们的 sqlite,现在我必须修复最后一段代码才能填充时间表,而不是给我这个错误。

Fatal error: Non-static method SQLite3::open() cannot be called statically in /home/server/public_html/current-list.php on line 57

$row_num    = 0;
if ($dbh = SQLite3::open($sked_path))
{
    $qsql = "SELECT rowid,* FROM sked ORDER BY sk_dow_num, sk_time_start, sk_time_end";
    $dres = SQLite3::query($dbh, $qsql);

    if (SQLite3::num_Rows($dres) > 0)
    {
        $last_dow   = "";
        $last_start = "0000";
        $last_end   = "0000";
        while (sqlite_has_more($dres))
        {
            $ska   = Sqlite3Result::fetchArray($dres, SQLITE3_ASSOC);
            $rid   = $ska['rowid'];
            $dow   = $ska['sk_dow_name'];
            $start = $ska['sk_time_start'];
            $end   = $ska['sk_time_end'];
    $title = preg_replace("/<br\s*\/*>/", " ", $ska['sk_show_title']);

            $show_dow   = strtoupper($dow);
            $show_start = strtoupper(formatTimeAmPm($start));
            $show_end   = strtoupper(formatTimeAmPm($end));
            $show_style = "";
            if (stristr($title, "Encore Show"))
                $show_style = " class=\"$text_style\"";

最佳答案

类似...

<?php
$dbh = new SQLite3;
if ( !$dbh->open($sked_path) ) {
    trigger_error('...error handling...', E_USER_ERROR);
}
else {
    $dres = $dbh->query('
        SELECT
            rowid,*
        FROM
            sked
        ORDER BY
            sk_dow_num, sk_time_start, sk_time_end
    ');
    if ( !$dres ) {
        trigger_error('...error handling...', E_USER_ERROR);
    }
    else {
        $ska = $dres->fetchArray(SQLITE3_ASSOC);
        if ( !$ska ) {
            onNoRecords();
        }
        else {
            do {
                doSomethingWithRowData($ska);
            }
            while( false!=($ska=$dres->fetchArray(SQLITE3_ASSOC)) );
        }
    }
}

(完全未经测试)

关于php - sqlite3 替换 sqlite_has_more,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32171780/

相关文章:

php - 连接表的 foreach 循环

php - 从 MYSQL 表中选择包含周末的两列之间的日期的行

iphone - sqlite 随机文件已加密或不是数据库

sqlite - 从命令行加载pcre.so

php - 服务器PHP内存限制是否适用于SQLite访问

sql - 在SQL中计算重复的组值

php - PHP 多进程的模式?

PHP 内存限制与 SQL 结果

php - 引用:什么是变量作用域?哪些变量可从何处访问?什么是“ undefined variable ”错误?

sql - 如何在 SQLite 中合并多个数据库文件?