Server side SQLite database with Google Web Toolkit or JQuery - php

I have a large array of vehicle make and model data that I want to dynamically display on a web page. For example, when you select a vehicle make from a drop down menu the vehicle model dropdown is dynamically populated with an asynchronous call.
I would normally execute this with an AJAX call to a PHP script that would return the desired data from a server side database.
To remove the need for a PHP helper script, I would like to directly call a server side SQLite database.
Everything seems to indicate that server side SQLite databases are not meant to be queried with Google Web Toolkit or JQuery.
Is it possible to use a server side SQLite databases with Google Web Toolkit or JQuery?
Thanks as always!

a couple of datapoints:
both GWT and jQuery ultimately execute as JavaScript inside the browser. they don't have any access to the network stack beyond being able to initiate AJAX requests (HTTP).
SQLite isn't a server, it's a library embedded inside an executable. Most modern scripting languages (like PHP, Python, Ruby, etc) embed it in some library (either core or external).
both HTML5 and Google Gears use SQLite to provide client-side data storage to client-side JavaScript apps; but it's all running inside the browser and therefore fully client-side.
so.... there's no 'direct' route between GTW/jQuery to server-side SQLite

You might want to check out Google Gears. It integrates GWT and SQLite, so it might give you some clues and some sample code as to how this might work with an online application:
Google Gears is a library that enables
your web applications to work offline.
Currently it consists of three
modules: LocalServer for caching and
serving up your web app resources (ie.
html, javascript, images), a SQLite
Database for storing offline data, and
a WorkerPool for performing
asynchronous operations.
http://www.gwtsite.com/getting-started-with-gwt-and-google-gears/

There is a JDBC driver for SQLite, so you can provide (abstracted) access to this via GWT's RPC.

Related

Making a "page change" in a single page web app over a WebSocket using php

I am trying to make a single page web app that runs over a websocket for all server request. After the user logs in, I want the page to change the html to display a dashboard (first page).
I have a template for the dashboard already build from a previous version. I need to find a way to input database info into template and send the page over the websocket as a string for the javascript to display.
I don't know how to fill the template using php classes without hard coding it into the class, then turning it into a string so I can send it. The dashboard is very complex and has dynamically built menus for each users per their settings and permissions.
Am I looking at this whole problem wrong? I have some experience with MVC from ruby on rails/node.js, but unfortunately this app is stuck using php. Can I use a framework with the socket? Should I have the JS load the template through https and send the data over the socket? (The JS guy would not like that).
I am running Ubuntu, apache2, php7, Ratchet WebSocket(wss), composer, and MySQL all on AWS.
I would definitely let the frontend get the required data. You could use php as a backend to test the authentication, parse the request, get the data from the database and send it to the frontend. The frontend then would need to update the application using dom manipulation (think jQuery).
Or, php could send a generated view that would be shown in a div in the frontend.
In this setup, I would not recommend websockets, but just plain AJAX.
From what I gather from your question, you might be better of using a real SPA framework like AngularJS. It it just better in using the data you will get from the backend. You could then choose to use a PHP backend using AJAX or a Websocket backend like nodejs.

Architecture for syncing data with remote server

Current scenario :
There is a webservice (build in php/mysql). User filled data is stored on a remote server.
Issue is user has extremely bad internet connection, webservice is down most of the time. Is there a way to store data locally and sync it when internet is available?
Please note, user might not have database installed on his machine also there is no localserver to work with.
Even if user had some type of RDBMS installed on the box, you probably wouldn't have any way to communicate with it. You can use the HTML 5 Storage API, but it will not solve the connection issues.
And since localStorage (which you probably would use) is available directly only from JavaScript, you would have to make a complicated and fully functional JS application to utilize it.
Note: based on your profile, I would estimate that your JavaScript skills would not be adequate for such task.
If your target audience is mobile users, then you have another alternative: create a native application.
You would still be able to use HTML for the interface (using built in web browser components). But it also would let you have SQLite DB and file storage available on the mobile device, where you can cache the necessary data.
look at the features in HTML 5 for local storage
Typically I would go with IndexDB and then push the local data to the server once the connection is back
http://diveintohtml5.info/storage.html - Should give you a brief about the features and implementation.

Back-end processing in chrome extension

So I'm working on a chrome extension, which I'm pretty new to. I was wondering how exactly I can execute operations in this extension without having to host my own server. Basically, I'm trying to build an app that is going to interface with another website's API. The Google documents talk about how I can use html, css, and javascript in my extension, but in order to interface with this API, I would need to use something like PHP (which I know) or ruby (which I don't). But PHP only executes server side. It seems pointless to host a server just to do that, it should be possible to do client side. So basically, what's the procedure for building code (not HTML, CSS, or JS) to execute client side in a chrome extension, whether that be for working with an API or just for general processing? Languages like Java and Python work for this API too (not JS) but that seems like it would be more difficult to then reintegrate the information they return into the displayed HTML/CSS.
Sorry if that's a rambling question, I'm really new to this. Thanks in advance
Like you said, You won't be able to use PHP, Ruby or Java in the browser. You can only use JavaScript.
Why do you need server side client for the API? You may can do your call with JavaScript ? Otherwise you will need a sever.

PhoneGap won't accept php scripts

I'm new to phoneGap and I just found out, It doesn't accept php scripts.
My problem is I have a php script that returns information from a database.
When I convert the .php script to a .html script(with embedded php), the information is not returned to the browser.
What can I do to fix this ?
According to the PhoneGap FAQ, you can't use PHP with it:
Q: Can you use PHP/ASP/JSF/Java/.NET with PhoneGap?
A: A PhoneGap application may only use HTML, CSS, and JavaScript.
However, you can make use of network protocols (XmlHTTPRequest, Web
Sockets, etc) to easily communicate with backend services written in
any language. This allows your PhoneGap app to remotely access
existing business processes while the device is connected to the
Internet.

Access mysql db and server side scripts from local file

This is more general design kind of question. My major project is to create native app for Firefox OS. Which therefor means JavaScript, jQuery, HTML5 and css. This application should have several functions. But as a general design goes I need local html,css,js application running under firefox OS with ability to access server php scripts and mysql db, but because application is running on client side, I have a major problem with communication between application and server. Which technology, language, API or JS functions could I use for Login check, registration, messaging. How can I access server from local (on PC or Mobile Device) files. There is possibility that I'm missing some point or that my whole understanding of the problem is wrong, but is this possible and how?
Apps are built using standard Web technologies with additional metadata that allows the User Agent to discover, install, launch, and grant them additional privileges.
So says MDN.
The usual way to interact with remote, shared databases is to place a RESTful HTTP front end in front of them and access that with JavaScript/XMLHttpRequest.
XHR, WebSocket or TCPSocket.
FYR:
https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest
https://developer.mozilla.org/en/docs/WebSockets
There is no TCPSocket document on MDN, but you can study gaia email app.
https://raw.github.com/mozilla-b2g/gaia/master/apps/email/js/ext/gaia-email-opt.js

Categories