Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1116205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:16:03+00:00 2026-05-17T03:16:03+00:00

I am developing an iphone app that uses a php web service for all

  • 0

I am developing an iphone app that uses a php web service for all functionalities.
I am planning on creating model objects to communication between my UI and web service.

Is it better to create model classes on php to communicate between my iphone models and database? or is it ok to communicate directly from database to my model classes for iphone?

Which one of the following is the correct way of handling this communication?

  • iphone-ui- => iphone-model-classes => web-service ==> database
  • iphone-ui => iphone-model-classes => php-model-classes => web-service ==> database
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T03:16:03+00:00Added an answer on May 17, 2026 at 3:16 am

    Why use PHP at all? Just use the relevant database library and connect to the database directly from the device!

    There are lots of reasons why you might want something sitting between the phone and the database server:

    • Authentication
    • Data validation/integrity checking
    • Logging/auditing
    • Schema changes

    Full-fledged model classes may seem a bit heavyweight (especially since PHP doesn’t cache anything), but you need to decide on how you want to do stuff on the server side. In particular, you might want to use model classes and a persistence layer to avoid dealing directly with Sqlite/MySQL/Postgres/ODBC/blah.

    There are also plenty of reasons why PHP isn’t the best language for a web service…

    EDIT: I was playing Devil’s Advocate.

    A “connection” to a database is often just a TCP connection (though pretty much all modern POSIXish DBs support connecting via Unix sockets, which is somewhat more secure). You generally need to implement the DB’s protocol; the easiest way is to use the DB-provided C library (libpq5 for Postgresql 8.4, libmysqlclient16 for MySQL 5.1, etc). I’m pretty sure that iOS doesn’t include them by default (but IIRC old versions of OSX used to come with Postgres).

    However, this is very bad for security reasons:

    • Most Linux distributions configure DB servers to only listen on Unix sockets (i.e. you can’t connect to them via localhost). It’s much easier to control access (only people who can access the file can connect), and allows for easy authentication as well (you can get the user ID of the process on the other end of the connection, which means you don’t need passwords at all — this is the default config for Postgres).
    • Most configurations that allow connecting over TCP do so because Java DB libraries typically don’t support Unix sockets (because a “pure Java” implementation supposedly has advantages, despite the tiny amount of native code you’d need to use Unix sockets). Typically these only allow connections from localhost (not random places on the internet).
    • If you’re happy with the entire Internet having read-only access to the relevant tables, then it might be sensible. Otherwise, you’ll want some sort of access control:
      • Allowing the wider Internet to write to your database is bad. You can’t just embed a password into your app; the app will be cracked within a few days/weeks and, if an attacker is sufficiently curious, the password will be extracted.
      • Database access controls are per-DB or per-table, whereas you want to control access per-row (i.e. a user can see their own row in the “users” table, but not the row for other users).data for other users).
      • Databases servers typically don’t do any form of rate-limiting on account logins, making it trivial to do an online bruteforce attack.

    And again, you very rarely want the phone to talk directly to the database. It means your app stops working when you update the schema (a no-no; you’re not supposed to force users to upgrade). It might be possible to put together some views/triggers/etc as a compatibility layer. Icky.

    Secondly, relational databases are generally a bad fit for what real apps do. You want to scroll down a table view. Each cell is loaded from a database row. Each row is loaded over the network … ouch. (After using CoreData once, I never want to look back. It makes my life much easier. While I wouldn’t use it on the server side (our servers run Debian and our webservices are mostly written in Python), if I’m going to write the app in Objective-C, Core Data doesn’t add any more vendor lock-in — I don’t know anyone who takes GNUstep seriously.

    Instead, it helps to consider the API you want to present to the web client. Most web services (Facebook, Twitter, probably others) seem to present a fairly “dumb”, flat model of the world. Write the simplest thing that allows you implement the API you want. This might mean using model classes if it is sufficiently easy to do so (Google App Engine’s modeling abstraction is nice; based off of Django’s modeling abstraction, apparently).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm on developing iphone app that uses backend web service(django). To login the web
I am developing an iPhone app that uses a web based API that I
I am developing an iPhone app that polls an internet web service. The poll
I'm developing an iPhone app that uses the network. The iPhone communicate with my
I'm developing an iPhone app that uses the network. The iPhone communicate with my
I've been developing an iPhone app that uses a UIToolbar (in the context of
i am developing an iphone app that receive data from sql server through php
I am developing an iPhone app that displays several views, all acessed via Tab
I'm currently developing an iPhone App that uses Phonegap and HTML5. I use localstorage
I'm developing an iPhone app that needs a web login. As usual I call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.