Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Call SQL database from a distant server (iphone)

Hey,

I'm looking to call a database from a distant server (the database is not in the app directory but on the web), you know with php you use some function like mysql_connect

Thanks

— asked June 30th 2010 by Bizouerne Louis
  • iphone
0 Comments

3 Answers

  • try this, http://php.net/manual/en/book.mysql.php

    — answered June 30th 2010 by Todd Tompkins
    permalink
    0 Comments
  • You'd need a MySQL driver for the phone - which might be a problem.
    Most people wrap the database in a REST based web service.

    — answered June 30th 2010 by David Ashwood
    permalink
    0 Comments
  • The best way to do that is call a php file on your webserver with Titanium.Network.HTTPClient which handles all of the SQL calls then just return the result as a JSON object and load that in to your script with the 'xhr.onload' function of the Titanium.Network.HTTPClient

    — answered June 30th 2010 by Kevin Smithson
    permalink
    2 Comments
    • Thanks, but i am a noob about javascript, i prefer php :s

      — commented June 30th 2010 by Bizouerne Louis
    • There is no (easy) way to connect to a remote MySQL database other than calling a PHP script which fetches the data from the database and returns it to your Titanium application as either JSON or XML. Here is an example of how you call remote services in Titanium.

      — commented June 30th 2010 by Kevin Whinnery
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.