Jump to content

Sqlite2 code omzetten naar sqlite3 code


JohanV

Recommended Posts

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);
Link to comment
Share on other sites

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);
Link to comment
Share on other sites

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 by Ch0cu3r
Link to comment
Share on other sites

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 by JohanV
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.