Android Question MySql, PHP, B4A wait for query to finish

Oscarin

Member
I am using this tutorial
To connect to a MySQL DB, everything works fine, but I have a problem.
Sometimes I need for the query to finish before proceeding to the next line of code
This is what I want to do
I do a SELECT * FROM and base on the result I give a variable a TRUE or FALSE value and will do either an INSERT or an UPDATE, the problem is that because is asynchronous
the value never changes, I don't want to use the sleep function because I don't know how much time it will take for the result to be given, and I know that I can use the WAIT FOR but unfortunately I don't know where to put it and how to use it.
Any help would be appreciated.

PS
I am using the same code as the tutorial, just modified to my needs.
 

DonManfred

Expert
Licensed User
Longtime User
Most probably a mistake.
This is a second thread about the same Issue.
 
Upvote 0

Oscarin

Member
Yes, sorry about that, the thing is that I searched for this (my first post) and I was not able to find it
 
Upvote 0

Oscarin

Member
The PHP based solution is insecure, less powerful and slower than jRDC2.
Sorry to bother again, but insecure in what way?
We already have some projects in html/php running in our servers, that is why I don't want to load another piece of software just to run some small tasks
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Of course php is NOT insecure but you can't just call a DB function without adding security. Mostly it's not just calling some db functions from an app. There's more. And this is the strength of PHP (or any other server client). You can check if a request is valid/allowed (via user credentials/message signing, encryption, etc.). You can do enything with it.

Mostly apps directly calling db functions are not safe enough and not accepted by customers/security/regulation authorities, etc.
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
I would also agree with this. I used to roll my own PHP code to access remote databases, but now have switched to Laravel in PHP on the server side. Much easier to be sure that it is secure and as @kmantle says much more accepted by customers etc.

This may seem like overkill if you just want to get/store a small bit of data so it is worth considering your use case. SLIMPHP is also another option.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
One of the issue is SQL injection. Imagine a client send something like SELECT * FROM tbl_user WHERE admin = 1 or DELETE * FROM tbl_Products. The client also can read some users sensitive data like password and query all the database schemas if database user privileged not set correctly.

There are many more secure ways like web services or web API. If you have a VPS, JRDC2 is a better solution.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…