• 用PHP操作sqlite數據庫

    時間:2012年08月02日 點擊:344
    a、 如何連接sqlite數據庫?
      if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) {
      select * from sqlite_master;
      echo "數據庫連接成功!n
      ";
      } else {
      die($sqliteerror);
      }
      b、 如何列出數據庫中所有的表?
      if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) {
      $result = sqlite_array_query($db, 'select * from sqlite_master;');
      foreach ($result as $entry) {
      echo 'talbe name='.$entry['name']."
      n";
      echo 'sql='.$entry['sql']."
      n";
      echo "
      --------------------------------------------------------------------------------
      ";
      }
      sqlite_close($db);
      } else {
      die($sqliteerror);
      }}
      c、 對sqlite數據庫的查詢,以及結果集的顯示
      if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) {
      $result = sqlite_array_query($db, 'select name, email from user ', SQLITE_ASSOC);
      echo "user表查詢結果:
      n";
      echo " n name email
      n";
      foreach ($result as $entry) {
      echo ' '.$entry['name']." " $entry['email']."
      n";
      }
      echo ' ';
      sqlite_close($db);
      } else {
      die($sqliteerror);
      }
      d、 數據庫對象記錄的增加、刪除、修改
      sqlite_query($db, "INSERT INTO user VALUES('user".$i."'" ",'user".$i."@ hichina. com')");
      sqlite_query($db, "delete from user where user=’user99’");
      sqlite_query($db, 'UPDATE user SET email="lilz@ hichina .com" where name="user1"');

    贊助商鏈接

    熱門內容

    相關內容

    聯系我們

    聯系方式
    亚洲AV口工动漫在线观看无码