#1 2015-06-13 23:04:18

impulsmedia
Member
Registered: 2015-04-21
Posts: 64

php/MySQL and AppBuilder

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

Offline

#2 2015-06-13 23:17:41

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: php/MySQL and AppBuilder

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.

Offline

#3 2015-06-14 22:34:36

impulsmedia
Member
Registered: 2015-04-21
Posts: 64

Re: php/MySQL and AppBuilder

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:

 print_r($row['Name of the field']); 

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

$sql = "SELECT * FROM test";  

in my PHP script.


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

SetVar "MyQuery" "\x22SELECT * FROM test\x22;" "String"
SimplePost "URL.php" "sql:MyQuery" "Textarea2.Value"

Whats wrong?

Thanks for any advice

Offline

#4 2015-06-14 22:44:35

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: php/MySQL and AppBuilder

Hello Walter,

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

SetVar "MyQuery" "\x22SELECT * FROM test\x22;" "String"
SimplePost "http://www.getappbuilder.com/Humm/Sites/Getappbuilder/Views/Files/Samples/SimplePost/post.php" "sql:MyQuery" "Textarea2.Value"

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:

SetVar "MyQuery" "SELECT * FROM test;" "String"

Offline

#5 2015-06-17 14:30:28

Nelson
Member
Registered: 2015-04-21
Posts: 21

Re: php/MySQL and AppBuilder

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... smile

I'm definitely not in a hurry smile

Offline

#6 2015-06-17 16:38:22

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: php/MySQL and AppBuilder

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...

Offline

#7 2015-06-29 18:13:24

Nelson
Member
Registered: 2015-04-21
Posts: 21

Re: php/MySQL and AppBuilder

I would like to share an interesting alternative: http://codecanyon.net/item/mydb-your-fl … e/11582645

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

Offline

#8 2015-06-29 18:17:18

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: php/MySQL and AppBuilder

Hello,

Sound good too Nelson! Thanks for sharing! smile

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.