Quesion: How to connect with a SQLite database using php PDO

meer_the_coder

Administrator
Staff member
Quesion / Problem:

How to connect with a SQLite database using php PDO

Answer / Solution:

Code:
if(!isset($myPDO)){
  $myPDO = new PDO("sqlite:assets/db/ipdf-book-indexes.db");
  if($myPDO == null){
    print "Connection failed <br/>" ;
  }else{
    print "Connected  <br/>";
  }
  $select_index_query = "select * from '<table_name>'";
  $result_index = $myPDO->query($select_index_query);
  if($result_index != null){
    foreach($result_index as $row){
      $title = $row['<column_name>'];
    }
  }
}
Thanks
 
Top