Page 3 of 4

Re: HMGSCRIPT RELOADED!

Posted: Fri Jan 30, 2009 3:08 am
by Rathinagiri
Yes. This we have already discussed. :)

Is there a sample to send queries to a MySQL database maintained in a web server? Please help.

Re: HMGSCRIPT RELOADED!

Posted: Fri Jan 30, 2009 11:14 am
by Roberto Lopez
rathinagiri wrote:Yes. This we have already discussed. :)

Is there a sample to send queries to a MySQL database maintained in a web server? Please help.
My own code is not good to teach about this since, it handles tables with lots of fields and other complications, but, you can found useful simple code here:

http://www.freewebmasterhelp.com/tutorials/phpmysql/1

more specifically:

http://www.freewebmasterhelp.com/tutorials/phpmysql/4

Regards,

Re: HMGSCRIPT RELOADED!

Posted: Fri Jan 30, 2009 11:17 am
by Roberto Lopez
Roberto Lopez wrote: more specifically:

http://www.freewebmasterhelp.com/tutorials/phpmysql/4

Regards,
And, if you don't have access to a 'real' server, you can install EasyPHP (preconfigured apache php and mysql) and test locally.

Be aware that your firewall could impede the work of any of the components, so you must give right access privileges.

Regards,

Roberto.

Re: HMGSCRIPT RELOADED!

Posted: Fri Jan 30, 2009 11:34 am
by Rathinagiri
Thanks Roberto, I will check on this.

I am accessing real server only. :)

Re: HMGSCRIPT RELOADED!

Posted: Fri Jan 30, 2009 1:57 pm
by Rathinagiri
Thanks for throwing some light on the subject Roberto.

I can now create a html file by sending a query. Now, how to get the data in a grid/array (xBase) format? Should we convert from that html file?

Re: HMGSCRIPT RELOADED!

Posted: Fri Jan 30, 2009 1:58 pm
by Rathinagiri
Now I am happy that, HMGScript is having native support for unicode. :)

It is an added advantage for HMGScript.

Re: HMGSCRIPT RELOADED!

Posted: Fri Jan 30, 2009 2:40 pm
by Roberto Lopez
rathinagiri wrote:Thanks for throwing some light on the subject Roberto.

I can now create a html file by sending a query. Now, how to get the data in a grid/array (xBase) format? Should we convert from that html file?
The basic php samples that I've linked to in the previous message, send back to the browser a new html page that will be loaded automatically.

This is not useful to recover the data only, but, it is useful for displaying it.

If you want to recover data only (without page reloading), you must make your php scripts to return plain text or xml containing the data only. Here is when the AJAX concept come to help us :).

Basically you should use xmlhttprequest javascript object to execute your php script without page reloading.

the data sent by your php script is stored in 'responsetext' or 'responsexml' properties and you can do with it whatever you want.

This is I want to do to handle data requests in HMGSCRIPT.

Regards,

Roberto.

Re: HMGSCRIPT RELOADED!

Posted: Fri Jan 30, 2009 9:02 pm
by apais
Hola Roberto...

I'm wondering if you are considering the js->json->php->json->js chain for communications exchange.
Another one: will you use arrays as recordsets or build a specific object for that ?
Also: Sqlite would be a non-need-to-setup database for preliminar tests and proof of concept don't you think ?

Just trying to shed some light into the project ;)

Regards
Angel

Re: HMGSCRIPT RELOADED!

Posted: Sat Jan 31, 2009 12:12 am
by Rathinagiri
I had tried SQLite in our present HMG version.

IMHO MySQL is far better than SQLite. The important problem is that, SQLite doesn't have Logical, Date fields and everything except numbers is saved as char.

However, it can be used as an alternative.

Thank you apais.

Re: HMGSCRIPT RELOADED!

Posted: Sat Jan 31, 2009 12:44 pm
by Roberto Lopez
apais wrote:Hola Roberto...

I'm wondering if you are considering the js->json->php->json->js chain for communications exchange.
Another one: will you use arrays as recordsets or build a specific object for that ?
Also: Sqlite would be a non-need-to-setup database for preliminar tests and proof of concept don't you think ?

Just trying to shed some light into the project ;)

Regards
Angel
I've been working on this for the last two days and I already have a working mode, but, without an xbase interface yet.

I've wrote a JavaScript function that receive connection parameters (user,pass,server) and a SQL query (a SELECT command).

This function executes a PHP script that do the query (using MySql) and returns a recordset as text with field and record delimiters.

In the client, I receive the recordset as plain text via 'responseText' xmlhttprequest property.

Then, I split two times. One to obtain a records array and again on each record to obtain a fields subarray.

The result is a two dimensional array representing the recordset.

The basic (read-only) xbase functionality is pretty easy to implement on a recordset array (go, seek, locate, fieldget, etc.).

To write on this recordset will require to solve a lot of problems, but, it can be done. Basically each row retrieved should include a field that identify each row in the table as unique, so DELETE and UPDATE should work well to implement its xBase counterparts.

JSON, could be used too. But we should evaluate the size of the transferred recordset and processing time to decode/eval it on the client compared with delimited text.

Saludos,

Roberto.