php


How can I use and access an SQLite DB using PHP and Wamp Server?


I know PHP 5 already supports SQLite but for some reason I can't get it to work.
I followed the instructions from SQLite tutorial: Getting started. I also made sure that the following are not commented out from php.ini:
extension=php_pdo_sqlite.dll
extension=php_sqlite.dll.
But when I open the PHP file from localhost using Firefox, I get this error:
Fatal error: Class 'SQLiteDatabase' not found.
I'm on Windows by the way, if that info matters.
What may be the cause of this problem?
I think the class SQLiteDatabase is from the extension sqlite rather pdo_sqlite. So you could enable the sqlite extension, or use PDO instead:
<?php
$conn = new PDO('sqlite:c:/mydb.sq3');
$conn->exec('some sql query');
On Windows you need to have the following set in your ini:
extension=php_pdo.dll
extension=php_sqlite.dll
I recommend you read this page in the manual.
Class SQLiteDatabase is an object from sqlite library, which support was dropped in PHP 5.4, but on various systems and configuration could be disabled in an earlier releases, as this library was long time marked as going to be deprecated.
Library php_sqlite.dll (Windows) or php_sqlite.so (Linux) is no longer supported in newer versions of PHP and was replaced with php_sqlite3.dll or php_sqlite3.so respectively.
You can:
Try to find php_sqlite.dll (php_sqlite.so) somewhere in the Internet. Links like this or this may be helpful for you. However, you'll have to carefully match old SQLite library file to your PHP's platform (x64 or x86), build engine (VC6, VC9 or VC11), version (5.x) and type (TS for thread safe or NTS for non-thread safe). This might be a hard task.
Leave php_sqlite.dll (SQLiteDatabase) behind and ship toward new php_sqlite3.dll (SQLite3 object). You have to first use a tool like SQLite Studio to convert your database file from 2.1 to 3.0 (size can be lowered by even a half) and then carefully compare SQLite and SQLite3 PHP manual pages to change necessary objects and functions call.
If option two, note that this shouldn't be a hard work, as changes aren't that big. For example, what I've learned so far:
SQLiteDatabase -> SQLite3,
SQLiteDatabase::unbufferedQuery -> SQLite3::query,
SQLiteResult::fetchAll(SQLITE_*) -> SQLite3Result::fetchArray(SQLITE3_*) etc.
As for fetching, in old SQLite we had:
$rowsIMEI = $db->unbufferedQuery($imeiSQL)->fetchAll(SQLITE_ASSOC);
foreach($rowsIMEI as $r)
{
...
}
While, in new SQLite3 we should:
$rowsIMEI = $db->query($imeiSQL);
while($r = $rowsIMEI->fetchArray(SQLITE3_ASSOC))
{
...
}
Other changes requires similar amount of work, so this shouldn't be a life-time process.
I, of course, strongly advice anyone to go forward and choose second option. Progress is in most cases the better one of two available options.

Related Links

PHP calling in more than 1 Tweet
PHPExcel - How to apply borders to dynamic range of cells loaded from mysql data
CodeIgniter Active record update not working
Creating MySQL leaderboard
JSON_BIGINT_AS_STRING removed in php 5.5?
Calling a Model Function in View?
PHP Regex: Extracting content from piped curly braces
Merge these array values into a new array?
Compare directory contents to database column in Joomla
How to access the html contents in the php code segment within the same php file?
How to change the index name of array
New line chr in twitter feed breaks JSONP
FFmpeg failed to transcode - Error while opening encoder for output stream
need ideas for remote authentication (Wordpress) [closed]
get parent array name after array_walk_recursive function
How To Insert From Data From PHP to MySQL DB

Categories

HOME
elasticsearch
verification
yahoo-weather-api
qc
concurrency
foaf
loopbackjs
out-of-memory
websocket
cryptography
gentelella
anchor
gtk
locationmanager
alljoyn
graphdb
chromecast
fullcalendar-scheduler
jpa-2.0
uima
nose
http-authentication
backtracking
stackexchange.redis
password-generator
window-managers
fstar
python-imageio
mdns
windowsiot
quick-nimble
rust-cargo
testlink
nsuserdefaults
installanywhere
strapi
elastica
microkernel
imgur
game-center
netapp
pyttsx
zend-form
doctrine-extensions
docker-ucp
ipp-protocol
bit-shift
gcal
section508
cyanogenmod
rm
roracle
jgrapht
ptvs
dtd
glassfish-4.1
rustdoc
hmmlearn
decoder
visual-studio-monaco
zynq
gcloud-node
traversable
jeasyui
django-redis
flush
ioctl
myfaces
outlook.com
python-cffi
linuxbrew
ibm-was
astropy
gql
swagger-maven-plugin
android-handler
dbmigrate
sablecc
python-c-extension
sql-processor
google-hangouts
juttle
thoughtworks-go
smacss
maven-central
.htpasswd
fileshare
sqlbindparameter
compiler-flags
vlab
microformats
cmath
xalan
multiscaleimage
gitx
playorm
coordinate
first-class
cakeyframeanimation
radscheduler
botnet
icicles
wmd-editor
rakudo
motif
objectinstantiation

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App