sqlite 数据库是否同时在服务器和客户端设备上创建?
Is sqlite database creted on both server and client's device?
我最近将我的网站文件更新到我的 server.but 我的 sqlite 数据库已在服务器上创建,但我希望它位于访问者的设备上。我认为 sqlite 用于网站的离线目的,我有点困惑请帮助我
我的脚本:
class MyDB extends SQLite3 {
function __construct() {
$this->open('mysqlitedb.db');
}
}
$db = new MyDB();
它是在我的服务器上创建的,而不是在设备上创建的
您的数据库可以位于客户端设备或服务器端,甚至可以同时位于这两个位置。这真的取决于你的要求。如果您的每个设备都想在设备上保存自己的数据,那么在客户端设备中拥有一个数据库就足够了。如果您想在任何集中位置保存所有数据,您可以选择位于服务器上的数据库。
Sq-lite 是一种轻量级 DBMS,主要用作客户端 DBMS,不建议用作服务器端实现。
另外,Firefox 不支持 SQLite 数据库(在网页中)。它不再是 HTML5 规范的一部分。 IndexedDB 是标准化数据库:http://www.w3.org/TR/IndexedDB/ Mozilla,Chrome 和其他公司正在致力于此。
您拥有的编码是 PHP,这是一种服务器端语言,它将在服务器上执行和执行其所有任务,包括数据库创建。
我建议您在 SQ-Lite 上使用 IndexedDB,并使用 javascript 来处理它。
前
var todoDB = (function() {
var tDB = {};
var datastore = null;
// TODO: Add methods for interacting with the database here.
// Export the tDB object.
return tDB;
}());
/**
* Open a connection to the datastore.
*/
tDB.open = function(callback) {
// Database version.
var version = 1;
// Open a connection to the datastore.
var request = indexedDB.open('todos', version);
// Handle datastore upgrades.
request.onupgradeneeded = function(e) {
var db = e.target.result;
e.target.transaction.onerror = tDB.onerror;
// Delete the old datastore.
if (db.objectStoreNames.contains('todo')) {
db.deleteObjectStore('todo');
}
// Create a new datastore.
var store = db.createObjectStore('todo', {
keyPath: 'timestamp'
});
};
// Handle successful datastore access.
request.onsuccess = function(e) {
// Get a reference to the DB.
datastore = e.target.result;
// Execute the callback.
callback();
};
// Handle errors when opening the datastore.
request.onerror = tDB.onerror;
};
SQlite 不是真正的 RDBMS,而是单个文件。因此,您不能像使用 MySQL 和 PostgreSQL 数据库那样进行远程连接。此外,从某种意义上说,SQlite 不是支持事务和数据类型的数据库。如果您需要数据库服务器连接并将数据保存在一个地方,那么您应该替换 SQlite。
我最近将我的网站文件更新到我的 server.but 我的 sqlite 数据库已在服务器上创建,但我希望它位于访问者的设备上。我认为 sqlite 用于网站的离线目的,我有点困惑请帮助我
我的脚本:
class MyDB extends SQLite3 {
function __construct() {
$this->open('mysqlitedb.db');
}
}
$db = new MyDB();
它是在我的服务器上创建的,而不是在设备上创建的
您的数据库可以位于客户端设备或服务器端,甚至可以同时位于这两个位置。这真的取决于你的要求。如果您的每个设备都想在设备上保存自己的数据,那么在客户端设备中拥有一个数据库就足够了。如果您想在任何集中位置保存所有数据,您可以选择位于服务器上的数据库。
Sq-lite 是一种轻量级 DBMS,主要用作客户端 DBMS,不建议用作服务器端实现。
另外,Firefox 不支持 SQLite 数据库(在网页中)。它不再是 HTML5 规范的一部分。 IndexedDB 是标准化数据库:http://www.w3.org/TR/IndexedDB/ Mozilla,Chrome 和其他公司正在致力于此。
您拥有的编码是 PHP,这是一种服务器端语言,它将在服务器上执行和执行其所有任务,包括数据库创建。
我建议您在 SQ-Lite 上使用 IndexedDB,并使用 javascript 来处理它。
前
var todoDB = (function() {
var tDB = {};
var datastore = null;
// TODO: Add methods for interacting with the database here.
// Export the tDB object.
return tDB;
}());
/**
* Open a connection to the datastore.
*/
tDB.open = function(callback) {
// Database version.
var version = 1;
// Open a connection to the datastore.
var request = indexedDB.open('todos', version);
// Handle datastore upgrades.
request.onupgradeneeded = function(e) {
var db = e.target.result;
e.target.transaction.onerror = tDB.onerror;
// Delete the old datastore.
if (db.objectStoreNames.contains('todo')) {
db.deleteObjectStore('todo');
}
// Create a new datastore.
var store = db.createObjectStore('todo', {
keyPath: 'timestamp'
});
};
// Handle successful datastore access.
request.onsuccess = function(e) {
// Get a reference to the DB.
datastore = e.target.result;
// Execute the callback.
callback();
};
// Handle errors when opening the datastore.
request.onerror = tDB.onerror;
};
SQlite 不是真正的 RDBMS,而是单个文件。因此,您不能像使用 MySQL 和 PostgreSQL 数据库那样进行远程连接。此外,从某种意义上说,SQlite 不是支持事务和数据类型的数据库。如果您需要数据库服务器连接并将数据保存在一个地方,那么您应该替换 SQlite。