Click here to Skip to main content
13,088,305 members (52,928 online)
Rate this:
Please Sign up or sign in to vote.
See more:

Has a c++ .exe application writes and reads a sqlite database every one second.
Has a php file writes and reads the same sqlite database every one second.

Journal files are created locking the database, i want to turn off the journal files completely.

on the c++ side this is the code to turn off the journal files:

sqlite3_exec(database, "PRAGMA synchronous=OFF", NULL, NULL, &errorMessage);
sqlite3_exec(database, "PRAGMA count_changes=OFF", NULL, NULL, &errorMessage);
sqlite3_exec(database, "PRAGMA journal_mode=OFF", NULL, NULL, &errorMessage);
sqlite3_exec(database, "PRAGMA temp_store=OFF", NULL, NULL, &errorMessage);

The above code is working fine, so if only the .exe application is accessing the db no journal files are created. But from the php side the journal files are being created.

So from the php pdo side what statements should i use to turn off the journal files?
Posted 9-May-13 3:31am
Zoltán Zörgő 9-May-13 9:51am
Have you tried: $query = sqlite_exec($database, "PRAGMA journal_mode=OFF", $error);?
amarasat 9-May-13 10:57am
I understood the issue now, i asked for a solution in php pdo, but the solution you gave me is the regular php sqlite function. Please let me iknow how do i turn off journal mode using php pdo
amarasat 9-May-13 10:14am
global $database, $error;
$database = new PDO($dir) or die("cannot open the database");

$mainQuery = sqlite_exec($database, "PRAGMA journal_mode=OFF", $error);
echo "Unable to turn off journal";

<br />
Warning: sqlite_exec() expects parameter 1 to be resource, object given in C:\xx\xx\.php on line 21<br />
Unable to turn off journal
amarasat 9-May-13 10:25am
$mainQuery = "sqlite_exec($database, PRAGMA journal_mode=OFF, $error)";

<br />
Catchable fatal error: Object of class PDO could not be converted to string in C:\xx\xx\.php on line 21<br />

in both the comments line 21 is $mainQuery =
Zoltán Zörgő 9-May-13 15:41pm
Of course you can not mix pdo with regular one. Try this:
$db = new PDO("sqlite: myDatabaseFile.sqlite");
$db->query("PRAGMA synchronous = OFF");
amarasat 13-May-13 12:06pm
Yes that's what i have tried and it has worked. I also have to turn off temp_store and synchronous to get a full journal less state. thanks for your help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 9 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100