JohanV Posted November 19, 2013 Share Posted November 19, 2013 Hallo, Ik heb hier een website die nog op sqlite 2 werkte en ik probeer deze nu om te zetten naar sqlite3 . Maar ik zit een beetje vast. ik zou onderstaande code in een sqlite3 code moeten omzetten maar het lukt me maar niet $sqlite_query = sqlite_query($sqlite_db, "SELECT * FROM categorie_lijst order by categorie"); $data = sqlite_fetch_all($sqlite_query, SQLITE_ASSOC, true); Quote Link to comment https://forums.phpfreaks.com/topic/284052-sqlite2-code-omzetten-naar-sqlite3-code/ Share on other sites More sharing options...
ignace Posted November 19, 2013 Share Posted November 19, 2013 English please. And what exactly is the problem? Quote Link to comment https://forums.phpfreaks.com/topic/284052-sqlite2-code-omzetten-naar-sqlite3-code/#findComment-1458962 Share on other sites More sharing options...
JohanV Posted November 19, 2013 Author Share Posted November 19, 2013 Ow sorry i posted this in de wrong forum. But any way, i can ask this also here . I need to make from a sqlite2 code a working sqlite3 code, but i'm stuck at this part. $sqlite_query = sqlite_query($sqlite_db, "SELECT * FROM categorie_lijst order by categorie"); $data = sqlite_fetch_all($sqlite_query, SQLITE_ASSOC, true); Quote Link to comment https://forums.phpfreaks.com/topic/284052-sqlite2-code-omzetten-naar-sqlite3-code/#findComment-1458970 Share on other sites More sharing options...
Ch0cu3r Posted November 19, 2013 Share Posted November 19, 2013 sqlite_* functions are for SQLite2.x only if you want to use SQLite3.x then you need to use PDO with the SQLite driver or use the SQLite3 class Quote Link to comment https://forums.phpfreaks.com/topic/284052-sqlite2-code-omzetten-naar-sqlite3-code/#findComment-1458978 Share on other sites More sharing options...
JohanV Posted November 19, 2013 Author Share Posted November 19, 2013 (edited) ... that is what i'm asking how to make this work using sqlite3 class ... i can't figure it out ...and, pdo is no option Edited November 19, 2013 by JohanV Quote Link to comment https://forums.phpfreaks.com/topic/284052-sqlite2-code-omzetten-naar-sqlite3-code/#findComment-1458980 Share on other sites More sharing options...
Ch0cu3r Posted November 19, 2013 Share Posted November 19, 2013 (edited) have you look at the example code for SQLite3 query fuction. Quoted from the manual Example #1 SQLite3::query() example <?php $db = new SQLite3('mysqlitedb.db'); // replaces sqlite_open() $results = $db->query('SELECT bar FROM foo'); // replaces sqlite_query() while ($row = $results->fetchArray()) { // replaces sqlite_fetch_all() var_dump($row); } ?> Edited November 19, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/284052-sqlite2-code-omzetten-naar-sqlite3-code/#findComment-1458981 Share on other sites More sharing options...
JohanV Posted November 19, 2013 Author Share Posted November 19, 2013 (edited) Yes i used that page i tried this but the limit 4 argument seems not to work? dam i'm stupid in this... $db = new SQLite3('../db/film_lijst-sqlite3.db'); $db_result = $db->query("SELECT id , cat_id , titel,beveiligd, tekst, tumb_file FROM film ORDER BY id DESC LIMIT 4 "); $result = $db_result->fetchArray(); //sqliteversion 2 //$sqlite_db = sqlite_open("../db/film_lijst.db", 0666, $sqliteError) or die ($sqliteError); //$sqlite_query = sqlite_query($sqlite_db, "SELECT id , cat_id , titel,beveiligd, tekst, tumb_file FROM film ORDER BY id DESC LIMIT 4 "); //$data = sqlite_fetch_all($sqlite_query, SQLITE_ASSOC, true); foreach ($data as $result) { //Categorie bepalen $categorie =$db->querySingle("SELECT categorie FROM categorie_lijst WHERE id = '". $result['cat_id']."' "); //sqlite2 version //$sqlite_query_cat = sqlite_query($sqlite_db, "SELECT categorie FROM categorie_lijst WHERE id = '". $result['cat_id']."' "); //$categorie = sqlite_fetch_single($sqlite_query_cat); etc.... Edited November 19, 2013 by JohanV Quote Link to comment https://forums.phpfreaks.com/topic/284052-sqlite2-code-omzetten-naar-sqlite3-code/#findComment-1458989 Share on other sites More sharing options...
Ch0cu3r Posted November 19, 2013 Share Posted November 19, 2013 Oh my bad $results->fetchArray(); doesn't get all the results. it gets 1 row at a time. You need to change $data = $results->fetchArray(); foreach ($data as $result) to while($result = $results->fetchArray()) Quote Link to comment https://forums.phpfreaks.com/topic/284052-sqlite2-code-omzetten-naar-sqlite3-code/#findComment-1458991 Share on other sites More sharing options...
JohanV Posted November 19, 2013 Author Share Posted November 19, 2013 ye that worked TY Ch0cu3r , I hope i can fix the rest of the script now Quote Link to comment https://forums.phpfreaks.com/topic/284052-sqlite2-code-omzetten-naar-sqlite3-code/#findComment-1458993 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.