如何构建可以离线运行的php mysql应用程序 [英] how to build a php mysql application that works offline

查看:89
本文介绍了如何构建可以离线运行的php mysql应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,可以在线将数据存储在MySQL数据库中.它还使用PHP代码检索数据,在服务器上执行计算,并将结果发送回用户.

I have a web applications that stores data in a MySQL database on-line. It also retrieves data using PHP code, performs calculations on the server and sends the result back to the user.

数据非常简单:名称,说明,价格,增值税,按小时收费,这些费用是从数据库中读取并在服务器端进行处理的.

Data it's quite simple: names, descriptions, prices, VAT, hourly charges that are read from the database and manipulated on the server side.

客户端通常在互联网连接不良或不可用的环境中工作.在这种情况下,我希望客户能够脱机工作:输入新名称,描述,价格,并使用上一个增值税执行计算.然后,在连接可用后立即同步所有数据.

Often client work in environments where the internet connection is poor or not available. In this case I would like the client to be able to work offline: enter new names, descriptions, prices and use the last VAT to perform calculations. Then synchronise all data as soon as a connection is available.

现在的问题是,我不知道实现此目标的最佳方法或技术是什么.不用担心,我不是要为我编写代码.您能给我解释一下构建这样一个系统的正确方法是什么吗?

Now the problem is that I do not know what is the best way or technologies for achieving this. Don't worry, I am not asking to write code for me. Can you just explain to me what is the correct way to build such a system?

有没有一种简单的方法可以在本地使用我的在线MySQL和PHP代码?

Is there a simple way to use my online MySQL and PHP code locally?

我应该将所需的数据保存在本地文件中,用JavaScript重建计算,在本地执行它们,然后在数据库可用时同步数据.

Should I save the data I need in a local file, rebuild the calculation in JavaScript, perform them locally and then synchronise the data if database is available.

我应该使用两个MySQL数据库,一个是本地数据库,还是一个在线数据库,并在数据可用时在两者之间进行同步吗?如果是,我应该使用哪种技术(语言)来执行此操作?

Should I use two MySQL database, one local and one online and do a synchronisation between the two when data is available? If yes which technology (language) shall I use to perform this operation?

如果可能的话,我想从过去从事类似项目的PHP编码人员那里得到一个答案,可以为我提供有关框架结构和使用技术的详细信息.请记住,我是这种编写应用程序的新手,如果您能抽出几分钟并向我解释一切,例如我六岁或愚蠢(我是!),我将不胜感激

If possible, I would like an answer from PHP coders that worked on a similar project in the past and can give me detailed information on framework structure and technology to use. please remember that I am new to this way of writing application and I would appreciate if you can spare few minutes and explain everything to me like if I am six year old or stupid (which I am!)

我非常感谢您的帮助和建议.

I really appreciate any help and suggestion.

Ciao

Donato

推荐答案

基本上有3种方法:

版本1:老派":PHP-Gtk +和bcompiler

  • 首先,如果尚未这样做,则需要将业务逻辑与表示层(HTML,模板引擎等)和数据库层分开
  • 然后调整您的数据库层,使其可以与备用数据库一起使用(想到本地SQlite)并在再次联机时执行同步
  • 最后使用PHP-Gtk +创建一个新的UI并使用bcompiler打包所有这些内容

版本2:标准":随身携带服务器

  • 查看Server2Go,WampOnCD和朋友以创建可双击的网络服务器"(从 Z-WAMP 开始)
  • 您仍然需要像版本1中那样调整数据库层
  • Look at Server2Go, WampOnCD and friends to create a "double clickable webserver" (Start at Z-WAMP)
  • You still need to adapt your DB layer as in Version 1

版本3:"Web 2.x":将应用程序从服务器移至浏览器

  • 将应用程序逻辑从服务器端(PHP)移至客户端(JS)
  • 仅使服务器部分(PHP)成为数据访问或同步层
  • 如果您离线,则使用HTML5离线功能将数据访问权限替换为本地数据,如果在线则重新同步

哪个最好?

这取决于您拥有什么和想要什么.如果您的大多数业务逻辑是使用PHP的,那么将其移动到浏览器中可能会非常昂贵-请注意,这还会产生一类全新的安全噩梦.我个人不建议采用这种方式移植,但是如果后备数据库不是太大,我还是建议将其用于新应用程序.

This depends on what you have and what you want. If most of your business logic is in PHP, then moving it into the browser might be prohibitingly expensive - be aware, that this also generates a whole new class of security nightmaares. I personally do not recommend porting this way, but I do recommend it for new apps, if the backing DB is not too big.

如果您选择保留PHP业务逻辑,那么1到2之间的选择通常是您的应用程序具有多少UI的质询-如果只有少数CRUD形式,则1.可能是个好主意-绝对是最便携的(就随身携带而言).如果不是,请选择2.

If you chose to keep your PHP business logic, then the desicion between 1 and 2 is often a quiestion of how much UI does your app have - if it's only a few CRUD forms, 1. might be a good idea - it is definitly the most portable (in the sense of taking it with you). If not, go with 2.

这篇关于如何构建可以离线运行的php mysql应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆