Posted By

mviera on 11/12/09


Tagged

SQLite


Versions (?)

How to use the SQLite Objetct Oriented Interface


 / Published in: PHP
 

  1. <?php
  2.  
  3. if (!$bd = new SQLiteDatabase('database.sqlite', 0666, $error))
  4. die($error);
  5. $sql = "SELECT * FROM table_name";
  6. $data = $db->query($sql);
  7. $data_count = $data->numRows();
  8. if ($data_count != 0) {
  9. for ($i=0; $i<$data_count; $i++) {
  10. echo "$data->fieldName($i)";
  11. }
  12. while ($tuple = $data->fetch()) {
  13. echo "$tuple['name']<br>";
  14. echo "$tuple['description']<br>";
  15. echo "$tuple['prize']<br>";
  16. }
  17. }
  18. unset($bd);
  19.  
  20. ?>

Report this snippet  

You need to login to post a comment.