0

如何连接到 sqlite 数据库?我打算用我的应用程序分发一个数据库,其中已经创建了所有表,所以我不需要创建一个新的数据库或表,只需分发它。

到目前为止,我有使用 mysql 的经验,我使用过类似的连接字符串

<?php session_start();
// DATABASE CONNECTION

$hostname = 'localhost';       
$dbname   = 'xxxxxxxxxxxx'; 
$username = 'xxxxxxxxxxxx'; 
$password = 'xxxxxxxxxxxx'; 

// Let's connect to host
mysql_connect($hostname, $username, $password) or DIE('Connection to host is failed, perhaps the service is down!');
// Select the database
mysql_select_db($dbname) or DIE('Database name is not available!');
?>

建立连接后,我开始使用 mysql_query 和 mysql_fetch_array 等插入 > 选择 > 删除和更新表值。

但是这个过程在 SQLITE 中有何不同。感谢所有帮助。我是sqlite的新手。

4

1 回答 1

0

Sqlite 是一种轻量级的 sql 形式,它没有服务器/客户端。所以你直接“连接”到文件(或内存)。

您可以$db = sqlite3_open(":memory:");使用$db = sqlite3_open("mydatabase.db");.

更多信息请访问http://www.php.net/manual/en/intro.sqlite3.php

于 2013-08-03T15:58:54.273 回答