Ways to store php into a data source (not mysql) - php

I was wondering if there is any kind of alternative to MySQL DB's.
It would be great if I could use MySQL db's but i don't want to ask the user to create a db as they'd find it to complicated and give up (non-web savvy target market). I cant store the data on one of mine remotely as there is just too much data and that's asking for trouble.
Also, the target market for my product are people that use one host. This host they use does not allow users to create MySQL db's. So I'm looking for an alternative where I can store personal data for the users to read and write. Maybe something that PHP can read and write to?
Any suggestions?
Is it possible to have a normal DB (Microsoft access DB file) on the server and PHP read/write to that?

What about SQLite?
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world.

sqlite is your choice:
In contrast to other database management systems, SQLite is not a separate process that is accessed from the client application, but an integral part of it.
http://php.net/manual/en/book.sqlite.php

Related

How do you connect to Azure's data storage from an external website?

I'm new to the whole idea of cloud programming to store information connected to mobile/web/applications.
I've been reading through tutorials and Microsoft seems to have done a good job tying everything together and making it fairly simple to adapt for your purposes.
However, all tutorials assume you will be using every aspect of your application from Microsoft's Azure (website, mobile services, data storage, database etc.).
I'm wondering if anybody knows of an example I can use to see how to connect an external website (one not hosted on Microsoft Azure) to their Data Storage (on Azure)?
What do the connection strings look like? Most importantly, how do you add the libraries/classes to the external server?
i.e.
user makes changes to record/entity on www.example.com (php)
www.example.com connects to data storage on Windows Azure
record/entity is update/inserted
It seems like there should be a fairly easy solution to this, or maybe I'm missing something?
Thanks for any help!
Microsoft's cloud offering (Azure) consists of different components which can be used to store data.
SQL Azure databases behave just like every other MS SQL Server database. Their scalability and flexibility is completely abstracted and you should be fine using any PHP+MSSQL sample or the normal documentation. In terms of connection strings: They also work as expected and for most scenarios you do not have to do anything different. This minimal sample shows how to use SQL Azure from PHP. You can just ignore the first part setting up the Azure application. You should be able use the same php code snippet from any other hosting scenario (e.g. Apache+PHP on Linux). If you have issues connecting you might want to have a look at the allowed ip addresses configuration of your server in the Azure management portal and allow the IP of your external server/hoster.
Azure storage (Blobs, Queues, Tables) are basically simpler means of storing data. You can use it through the azure sdk for php and have a look at the samples. Most of this article should apply to your scenario as well. Storage is cheaper for many scenarios compared to using a SQL database.
So to sum up: You don't have to to anything "special" for your scenario. Just use SQL Azure like any other database. Simply store files in Azure blobs.
As for any application spanning multiple data-centers: Be aware of latency. Round-trips to the database/storage will be more expensive (in terms of performance) than when hosting everything at one site. This can be a significant performance bottleneck depending on your application.

how to build a php mysql application that works offline

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?
Is there a simple way to use my online MySQL and PHP code locally?
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.
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?
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
There are essentially 3 ways to go:
Version 1: "Old school": PHP-Gtk+ and bcompiler
first, if you not have done so already, you need to separate your business logic from your presentation layer (HTML, templating engines, ...) and database layer
then adapt your database layer, so that it can live with an alternative DB (local SQlite comes to mind) and perform synchronisation when online again
Finally use PHP-Gtk+ to create a new UI and pack all this with bcompiler
Version 2: "Standard": Take your server with you
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
Version 3: "Web 2.x": Move application from server to browser
Move your application logic from the server side (PHP) to the client side (JS)
Make your server part (PHP) only a data access or sync layer
Use the HTML5 offline features to replace your data access with local data if you are offline and to resync if online
Which one is best?
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.
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.
I have worked with similar system for ships. Internet is expensive in the middle of the ocean so they have local web servers installed with database synchronization via e-mail.
We also have created simple .exe packages so people with no experience can install the system or update system...

Phonegap: populate local database with data from external server

I am writing an android application that needs to work both offline and online. In order to do that I need to get mysql database from external server and save that db to phones localdatabase so it can be read from there if user has no connection. Is it possible and if so, how can I do it?
Refer the following thread in which I have mentioned javascript frameworks which can be used to store data locally. The frameworks are using the standard local storage mechanism but they make it easier to store/retrieve and also make it portable across many platforms (this again depends on selection on the framework).
What to Use for PhoneGap Database Storage
Although you still need to load data from server.
This sounds like you need to write an API which does CRUD operations on a database.
There is no trivial way to simply do this directly with MySQL - you'll have to write one.
There are frameworks designed specifically for this, for example FRAPI: http://getfrapi.com/

Android connection to MySQL - Php or Servlet?

This is not a codefix question but please help me where possible.
I am developing an application which needs to store information in a database. This information needs to be stored off-device for security reasons (patient data).
I have explored using PHP as a bridge to the external MySQL database hosted locally via WAMP, however I have recently been informed of servlets and also of SQLite.
As I am learning these technologies under a limited time frame I need to know which to invest my time into to get the job done as easily as possible. I have no experience with any query language but I did get a simple login screen to work on Android using PHP and MySQL on WAMP using HTTP post/fetch within android.
Also, is it possible to store the information in SQLite within android and write that data to a server, which can then load the SQLite database again on re-launch?
Many thanks for your time!
From our expericence these kind of services need to work offline if possible. Both 3g and especially wifi has been unreliable in several occasions.
You do good if you save the data locally in e.g. sqlite database but be warned the data can get wiped on OS update or software update.
Also try to write your changes/additions in batches and servr updater can send all the batches that are not yet on the server. this way it's more reliable if you miss updates.
These kind of interfaces to another systems take a lot of time in testing. Consider getting a new timeframe in advance.
You will find more about Android connection to MySQL here

connect a database with externals tables

I never made something similar .
I have a system and i need to relate my data with external data (in another database).
My preference is get these data and create my own tables, but in this case when the other dbs are updated my personal tables will be obsolete.
So, basically i need to synchronize my tables with external tables, or just get the external data values.
I don't have any idea how i can connect and relate data from ten external databases.
I need to check if an user is registered in another websites basically.
Any help?
I am crrently doing something similar.
Easiset way I found is to pull the data in, though I do bi-directional syncronisation in my project you haven't mentionned this so I imagine it's a data pull you are aiming for .
You need to have user accounts on the other servers, and the account needs to be created with an ip instead of 'localhost'. You will connect from your end through mysql client using the ip of distant host instead of the ususal localhost.
see this page for a bit more info.
If, like me you have to interface to different db server types, I recommend using a database abstraction library to ease the managing of data in a seamless way across different sql servers. I chose Zend_db components, used standaline with Zend_config as they Support MySQL and MSSQL.
UPDATE - Using a proxy DB to access mission critical data
Depending on the scope of your project, if the data is not accessible straight from remote database, there are different possibilities. To answer your comment I will tell you how we resolved the same issues on the current project I am tied to. The client has a big MSSQL database that is is business critical application, accounting, invoicing, inventory, everything is handled by one big app tied to MSSQL. My mandate is to install a CRM , and synchronise the customers of his MSSQL mission-critical-app into the CRM, running on MySQL by the way.
I did not want to access this data straight from my CRM, this CRM should not ever touch their main MSSQL DB, I certainly am not willing to take the responsibility of something ever going wrong down the line, even though in theory this should not happen, in practice theory is often worthless. The recommandation I gave (and was implemented) was to setup a proxy database, on their end. That database located on the same MSSQL instance has a task that copies the data in a second database, nightly. This one, I am free to access remotely. A user was created on MSSQL with just access to the proxy, and connection accepted just from one ip.
My scipt has to sync both ways so in my case I do a nightly 'push' the modified records from MSSQL to the crm and 'pull' the added CRM records in the proxy DB. The intern gets notified by email of new record in proxy to update to their MSSQL app. Hope this was clear enough I realize it's hard to convey clearly in a few lines. If you have other questions feel free to ask.
Good-luck!
You have to download the backup (gzip,zip) of the wanted part(or all) of the Database and upload it to the another Database.
Btw. cronjobs wont help you at this point, because you cant have an access to any DB from outside.
Does the other website have an API for accessing such information? Are they capable of constructing one? If so, that would be the best way.
Otherwise, I presume your way of getting data from their database is by directly querying it. That can work to, just make a mysql_connect to their location and query it just like it was your own database. Note: their db will have to be setup to work with outside connections for this method to work.

Categories