Создал страницу : PHP: class TreeDB extends SQLite3 { function __construct() { $this->open('tree.db'); } } $db = new TreeDB(); $db->exec(' CREATE TABLE tree( id_tree INTEGER PRIMARY KEY, desc_tree , id_parent INTEGER )'); $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №1\',0)'); $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №2\',0)'); $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №3\',0)'); $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №4\',0)'); $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №5\',0)'); $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №6\',0)'); $result = $db->query('SELECT id_tree FROM tree'); print_r($result->fetchArray()); Дело в том что SELECT выводит только одну запись в чём проблема не могу понять....
А что возвращают insert'ы? И в exec запросы можно разделять точкой с запятой. --- Добавлено --- Для desc_tree не указан тип.
спасибо за подсказку по поводу exec =) сделал так PHP: $res[] = $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №1\',0)'); $res[] = $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №2\',0)'); $res[] = $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №3\',0)'); $res[] = $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №4\',0)'); $res[] = $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №5\',0)'); $res[] = $db->exec('INSERT INTO tree (desc_tree,id_parent) VALUES (\'Раздел №6\',0)'); выводит Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 )
пишет unknown error после SELECT --- Добавлено --- переделал в один exec всё тоже самое --- Добавлено --- пересоздал базу PHP: $db->exec(' CREATE TABLE tree( id_tree INTEGER PRIMARY KEY, desc_tree TEXT, id_parent INTEGER )'); --- Добавлено --- проблема в SELECT но я её в упор не вижу
Записи надо в цикле перебирать: PHP: $results = $db->query('SELECT id_tree FROM tree'); while ($row = $results->fetchArray()) { var_dump($row); } Слона блин не заметил)))