在服务器和客户端上都创建了sqlite数据库';s设备


Is sqlite database creted on both server and client's device?

我最近将我的网站文件更新到了我的服务器上。但我的sqlite数据库已经在服务器上创建,但我希望它在访问者的设备上。我觉得sqlite是用于离线目的的网站,我有点困惑plz帮我


我的脚本:

class MyDB extends SQLite3 { 
    function __construct() {
        $this->open('mysqlitedb.db');
    }
}
$db = new MyDB();

它是在我的服务器上创建的,而不是在设备上

您可以将数据库放在客户端设备或服务器端,甚至放在这两个位置。这真的取决于你的要求。如果每个设备都想在设备上保存自己的数据,那么在客户端设备中有一个DB就足够了。如果你想有一个集中的位置来保存你的所有数据,你可以选择一个位于服务器上的数据库。

Sq-lite是一种轻量级DBMS,主要用作客户端DBMS,不建议用作服务器端实现。


此外,Firefox不支持SQLite数据库(在网页中)。它不再是HTML5规范的一部分。IndexedDB是标准化数据库:http://www.w3.org/TR/IndexedDB/Mozilla、Chrome和其他公司正在进行这项工作。


您随身携带的编码是用PHP编写的,这是一种服务器端语言,它将在服务器上执行和执行所有任务,包括创建DB。


我建议您在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。