Setting Up SQLite3 PDO Drivers in PHP

General Tech Learning Aids/Tools 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

I'm working my way 'slowly' through the php101 tutorials and have got to number 9, where I need SQLite.

I've got SQLite3 running and can access via the CLI, (see screenshot of a little test DB) but when I try the tutorial scripts in php101, I get a blank browser screen. I now know this is because SQLite3 uses PDO (php101 is based on SQLite v2).

Couldn't post and image so CLI says:

SQLite version 3.7.2

Enter ".help" for instructions

Enter SQL statements terminated with a ";"

sqlite> select * from books;

1|The Lord of the Rings|J.R. Tolkien

Etc Etc

Rather than go backwards, I'm trying to figure out how to enable the SQLite3 PDO driver (which I know is named sqlite) but those who have posted on stackoverflow to date, seems to have the SQLite driver installed and enable already, so driver config was not actually explained.

(sorry could post an image) but phpinfo for PDO says:

PDO

PDO support | enabled

PDO drivers |mysql

pdo_mysql

PDO Driver for MySQL |enabled

Client API version |5.1.49

I've checked on www.phpro.org/tutorials/Introduction-to-PHP-PDO but it is not explained there either.

My System is Linux Ubuntu 10.10

Apache - version 2.2.16

PHP version 5.3.3

SQLite 3.7.2

I'm trying to get this running on localhost as a learning aid initally.

Can someone explain how to install/configure the SQLite3 driver.

profilepic.png
manpreet 2 years ago

It's all easy when you know how, eventually found a post on www.news.php.net which provided a clue.

So for anyone else stuck on this, just open a terminal and enter:

sudo apt-get install php5-sqlite

note don't put a 3 and the end just leave it as sqlite

You will have to restart your machine, if you then check phpinfo you will find an entry for SQLite and the drivers enabled for sqlite2 and sqlite (note sqlite is the SQLite3 driver)

Hope this helps someone else in the future.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.