Databases with Jquery Mobile - php

I have a couple of questions about using databases with Jquery Mobile.
When you are building a Jquery Mobile application, do you use regular PHP/MYSQL for login and contact forms?
What would happen if the user did not have a connection to the internet?
Is there a way to "cache" a database?
Sorry if these questions seem silly, I am new to Jquery Mobile.
Thanks friends.
Edit: The contact form will only have 3 or 4 inputs. The form is simply a small feedback form.

You could use any Backend technology you wanted, PHP and MySQL are great for this. I prefer PostgreSQL over MySQL but that's another debate.
As for client-side database you could use HTML5 Local Storage ( more on this here ), but for any server-side authentication / interaction you will need a internet connection.
For no internet connection IMHO I would show an error to the end user saying something like, "Services are not available" or "Please check your internet connection".
For Offline Application use you could look into these ( I have not tried any of these )
http://www.html5rocks.com/en/features/offline
http://gazpo.com/2011/08/html5-offline-applications/
http://html5doctor.com/go-offline-with-application-cache/
How to check for internet connection ( What others have tried )
Check if connected to a network; jQuery
JQuery Mobile Detected if there's internet Connection
Jquery Plugin for Detecting Internet Connection

It really depends on the type of data you are storing. Is there going to be a need to a decent amount of queries and stored procedures? Do you need triggers and rules to validate your data in your database?
The main question to ask is:
Do you need to build off of a schema? Or are you mainly going to be working with JSON objects?
If you plan on spending a lot of time in the database managing a schema and other rules then go with a MySQL or a SQL Server Express option. Both database engines are free and will allow you to manage your data easily.
However, if your data is based off JSON objects and does not really adhere to a relational model, I would go with a document oriented database like CouchDB.
http://couchdb.apache.org/
CouchDB was really made for websites that do not want to use a specific schema, but need some sort of storage system. You can store JSON documents in your database and query and retrieve data with simple HTTP.
Rather than being schema oriented like SQL databases, CouchDB is document oriented. A CouchDB database is a flat collection of documents.
Since you mentioned you were using PHP, below is a tutorial on getting starting with PHP and CouchDB.
http://wiki.apache.org/couchdb/Getting_started_with_PHP

i have one good suggestion.
if you want create jquery mobile then use phone gap.
its totally based on jquery and html.
its easy to develope and easy to connect with database.

Related

How can I save a user's actions on react components for future logins on any device?

I am sort of new to web programming so please bare with me...
Imagine I create a website in using React where you can play three-in-a-row. A logged in user plays and then exits the website and opens it on another device later from the same user account. I assume this would have to be done (and the same goes for even storing the user) by storing the data in a database. What are some common options here? I have a little bit of experience using MySql and php, but have heard there may be other options.
What techniques would be well suited for this type of web application?
Thanks for any input!
Yes, you will have to store the data in a database because you want to use it on different machines. As far as the specific database that's depending on the type of data you plan on storing and personal preference. I'd use a noSQL database if possible.

Can we use and manipulate mysql data with google spreadsheet vice versa in php?

I want to use google spreadsheet on my laravel website and i want to connect mysql data with this spreadsheet. and also i want to display spreadsheet in my website page and if user will update anything in spreadsheet then it will reflect in mysql and also if data will update in mysql table then also spreadsheet data will be change. So can you please suggest me is it possible or not? and if possible then explain me with best steps.
Thanks in advance!
Yes, you can.
By using the Google Sheets API to fetch data you can sync you SQL data with that with any programming language that supports HTTP calls, with an easier time to those where Google provides a client.
You could also use Apps Script to create a onEdit trigger that pushes the changed data to the MySQL table. This is by far the most elegant solution since you are not doing a full refresh every time, just grabbing the changes and pushing them over. Of course, this also requires you to have a receiving mechanism that is reachable by Apps Script, like a web-service.
Also, if you want to use data in tabular form (SQL) in your website, why not just do it all thru Google Sheets, without the SQL layer? You can use JavaScript to filter your data straight from the sheets. While it has some performance draw, it's most likely unnoticeable for the common user. And the performance difference should not appear unless you have a good SQL server setup.

Why api is used when you can fetch data directly from database using sql query?

I am a newbie to the web application. I just understood what is an api and why it is used by reading some online blog. But I was wondering why to use an api to fetch data(or insert data) when you can directly fetch data from database using PHP and mysql.(I am sorry if this question sounds stupid.) An answer with example would be great. Thanks
API are used to make communications more secure. With an API you can add encryption, different users and roles and a lot more. With MySQL you can not do that on the same level.
Future more, MySQL is a service, and if you work directly with it, it has to be open on a Port. Here you can not add not as well protection as you can on a Webserver.
An API can also add some logic. Maybe you want to control the input given by a request to it. Or maybe you want to have some additional calculations going on, before you make any INSERT or UPDATE to the database. This can help you to have your database clean.
If the System where the database and the API is located at, decides to change the database from lets say MySQL to PostgreSQL or anything else, every service connecting to it will have to change its code to make it work with the new environment.
So, an API can be more secure and has some standard everyone can rely on, even if the APIs background changes.

Passing data between forms in different applications

I have a situation here, I want data passed from application developed with PHP and MySQL to my ASP.Net Application. There is this application developed in PHP with MySQL database which was developed by another developer. I have a application or rather I am developing an application in ASP.net and I dont have access source of this application or the database. I want some data from that PHP application to passed to my ASP.net application. What I can do Is colaborate or ask that PHP developer to supply the data in the format I want (XML or Json or any other technology) but I dont think that is secured way to do so. So I want to ask here what is my option here. What should I ask the PHP developer so that I get data into my application using best and secured way.
If my question is not clear
Option 1: Create API to share the needed data across the 2 system
Option 2: Create Link servers to query from mySQL to MS SQL
You don't say how collaboratively you both work, but it sounds like the other developer will provide the data if you have a solution.
So, ask her to create a mySQL user that has read-only access to the database, then you can query it directly.

Android remote MySQL operations using a web service with php

I read some nice articles about how to connect to a remote MySQL database via Android.
Found some really interesting links here and here.
So the common way for getting data seems to be using some kind of webservice (interface, in this case a php script) which queries the db and renders the result in JSON (or XML) format. Then its possible to parse this output with the android JSON_Object implementation. So far so good.
Receiving data from the database and showing it up in a android listview was done in about minutes.
But what is the best practice for writing (inserting) data into tables?
Should a webservice be used here too? (or rather direct mysql conn)
What is the best method to push data to a webservice? (for ex. to insert a new entity in a database) and which format should be used?
In this case I do not use any html forms or anything to post the parameters. So how to post these parameters to the php script? (from within the android app!)
Of course this operation should be secure as well. Implementing a data manipulation machanism is bit more risky (in order to keep the db persistant)
I think, that many apps use some kind of DB, to synchronize data (ex: highscores).
So there should be a best practise for that.
I would recommend keeping anything database-specific hidden behind a web service.
If you build a dependency on MySQL into your application and later find that you need to change databases, the entire installed base has to be cut over. Think about the logistics of accomplishing that for a few minutes and you'll start to realize it's a nightmare.
Premiumsoft's Navicat for MySQL comes with a HTTP tunnel (PHP script) you might be able to use. It basically provides a method for doing anything to a MySQL database over HTTP.
I'd just make sure there are no licensing issues if you plan to distribute your app.

Categories