Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag 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.
ASKER CERTIFIED SOLUTION
Avatar of Yujin Boby
Yujin Boby
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial