Avatar of curiouswebster
curiouswebster
Flag for United States of America asked on

PHP connection to a SQLite database?

I need to use PHP to create a connection to a SQLite database.

Is there a similar call, like this connection to a MySql database?

// Creating a connection
$conn = new mysqli($servername, $username, $password);

Is this the trick?
<?php
   class MyDB extends SQLite3 {
      function __construct() {
         $this->open('test.db');
      }
   }
   $db = new MyDB();
   if(!$db) {
      echo $db->lastErrorMsg();
   } else {
      echo "Opened database successfully\n";
   }
?>

Open in new window


https://www.tutorialspoint.com/sqlite/sqlite_php.htm

Thanks.
DatabasesPHPScripting LanguagesApache Web Server

Avatar of undefined
Last Comment
Chris Stanyon

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Yujin Boby

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Chris Stanyon

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
curiouswebster

ASKER
I saw PDO, but thought it was a brand. Is it open source? Can you give me some input about how to use PDO?

I think PDO may answer my other question, where I was feeling more unstructured than I prefer to feel...

https://www.experts-exchange.com/questions/29217611/PHP-SQLite-need-function-to-execute-SQL-statement.html
SOLUTION
Chris Stanyon

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy