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
https://forums.phpfreaks.com/topic/284052-sqlite2-code-omzetten-naar-sqlite3-code/
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);

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);
}
?>

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....

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.