Вознакает ошибка:
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
Вот сам код:
$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;
Почему она возникает?