S
S
Svoboo2017-08-12 19:06:50
PHP
Svoboo, 2017-08-12 19:06:50

Why does SQLite3 error occur in php code?

An error occurs:

Warning: SQLite3::query(): Unable to prepare statement: 1, near "WITH": syntax error in DBClass.php on line 825
Fatal error: Call to a member function fetchArray() on boolean in DBClass.php on line 827

Here is the code itself:
$query = 'WITH 
                a as (
                        SELECT `id` FROM `'.DB::prefix('video').'` 
                        INDEXED BY "INDEX_TUBE_CAT_ID"
                        WHERE (`categoryId` = '.$array['categoryId'].') AND (`date` < '.time().') AND (`id` > '.$array['tubeId'].')
                        ORDER BY `id` LIMIT ' . $array['limit'] . '
                     ),
                b as (
                        SELECT `id` FROM `'.DB::prefix('video').'`
                        INDEXED BY "INDEX_TUBE_CAT_ID"
                        WHERE (`categoryId` = '.$array['categoryId'].') AND (`date` < '.time().')
                        ORDER BY `id` LIMIT (SELECT ' . $array['limit'] . ' - COUNT(*) FROM a)
                    )
                SELECT a.* FROM a union SELECT b.* FROM b';
        $similarId =  $this->sqlite->query($query); //825 строка

        while ($row = $similarId->fetchArray(SQLITE3_ASSOC)) { //827 строка
            $similarArray[] = $row['id'];
        }
        return $similarArray;

Why does it arise?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question