php/MySQL and AppBuilder


Walter Hiller

Hello David,

I just work hard on an connecting a MySQL database via Appbuilder, insert some data out of Appbuilder inputs, start a query and get the result back in one or more javascript vars. To do the things in PHP is not the problem, the question is how to "connect" PHP and JS? I did some test with SimplePost without success. Do you have a idea how to get forward?
Thanks in advance, Walter


decsoft

Hello Walter,

Connect PHP and JS sound a little confuse, since PHP is a server language and JS is a client language, then by definition their have different scenarios. Depend on what you wanted the answer can vary. Make HTTP request to a server in order to be processed by PHP is very simple by using actions like SimpleGet, SimplePost or the HttpClient control.

What data we can receive from a server and how to deal with it depend on every app. Take a look at the Report app sample, for example. This sample show us how we can parse JSON data into an HTML table. The JSON of the app sample is loaded directly from a file (included with the sample) but the sample also incorporates a "data.php" file, which show us how we can create (in a server) the JSON to be received and processed by the app.



Walter Hiller

Hello,
I know sometimes my questions are confused. But this simply is a result of my lack of unsderstanding - sorry for that!

I now worked out a solution to get back the results of a mysqli_query. I just use:

in my PHP script. Seperating the fields with | I get a useable array as result. This works fine as long as I define my query with

in my PHP script.

BUT as soon as I try to send the SQL -Query with SimplePost action, I get no result ..

Whats wrong?

Thanks for any advice


decsoft

Hello Walter,

Testing with the SamplePost app sample I can write something like this:

And works like expected, in the sense that I can get the into the "sql" POST variable the text "SELECT * FROM test";.

Maybe the problem is how you try to use the "sql" POST variable in PHP. First of all assert you receive such variable by simple "echo" it. Secondly assert you can use the content of such variable in the context you wanted to use. For example, maybe the quotes of the text cause the problem. Try something like this instead:



Nelson Hernánez

Interesting... I was also running some tests and I decided that for now (and for my purposes) its better to wait for a first stable version hopefully looking at having integration with some sort of embedded databases system such as SQLite... :)

I'm definitely not in a hurry =)


decsoft

Hello Nelson,

The problem is that access SQLite from the HTML5 API appear to be droped in the future and is currently not supported by IE, for example. Currently you can use plain text, JSON files and local storage in order to store and retrieve app data. And also can use HTTP calls in order to update or add new information from the app.

How the HTTP calls are made depends completely on the app, because many different servers/languages can be used for this purpose. Probably you no need to send SQL queries along internet, because you can prepare end points for your app calls in order to retrieve or set database information.

Unfortunatelly we can wait an entire life for view a SQLite support in web browsers Nelson...



Nelson Hernánez

I would like to share an interesting alternative: http://codecanyon.net/item/mydb-your-flatfile-database/11582645

A flat file database, very useful PHP class for storing data on a file.


decsoft

Hello,

Sound good too Nelson! Thanks for sharing! :)


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.