Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Android
  4. put orders from android and receive from PHP

put orders from android and receive from PHP

Scheduled Pinned Locked Moved Android
helpphpandroidsysadminsales
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndroidVH
    wrote on last edited by
    #1

    I have an Android application where customers can purchase and put orders Every customer can put order and I just have one `JSON` file in the `PHP` server to collect the orders from different customers The problem is if one customer puts his/her order, the `JSON` file shall be locked in order to prevent collision and if it is locked, how can another customer put order at the exact same time? To solve this issue, and for test, I decided to have a folder in the server where every customer (who is going to put an order) can put his unique ID there (uploading a text file with the name of the customer's ID) and I just read that folder to see who has put any order and then I delete the file which was uploaded by the customer indicating he/she has just put an order to be ready from another order from that customer (every customer creates a folder with his/her unique ID name to put detailed list of his/her orders and this is handled by PHP code) It works fine but does not seem to be a true manner from performance point of view Any suggestion?

    L D 2 Replies Last reply
    0
    • A AndroidVH

      I have an Android application where customers can purchase and put orders Every customer can put order and I just have one `JSON` file in the `PHP` server to collect the orders from different customers The problem is if one customer puts his/her order, the `JSON` file shall be locked in order to prevent collision and if it is locked, how can another customer put order at the exact same time? To solve this issue, and for test, I decided to have a folder in the server where every customer (who is going to put an order) can put his unique ID there (uploading a text file with the name of the customer's ID) and I just read that folder to see who has put any order and then I delete the file which was uploaded by the customer indicating he/she has just put an order to be ready from another order from that customer (every customer creates a folder with his/her unique ID name to put detailed list of his/her orders and this is handled by PHP code) It works fine but does not seem to be a true manner from performance point of view Any suggestion?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      The PHP server should be able to handle multiple orders, just like any other web server.

      A 1 Reply Last reply
      0
      • L Lost User

        The PHP server should be able to handle multiple orders, just like any other web server.

        A Offline
        A Offline
        AndroidVH
        wrote on last edited by
        #3

        The point is writing to the same file at the same time and as I searched it may create corruption

        L 1 Reply Last reply
        0
        • A AndroidVH

          The point is writing to the same file at the same time and as I searched it may create corruption

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Exactly why I made my comment. You should not try to write to a single file in a multi-user application; it makes no sense.

          1 Reply Last reply
          0
          • A AndroidVH

            I have an Android application where customers can purchase and put orders Every customer can put order and I just have one `JSON` file in the `PHP` server to collect the orders from different customers The problem is if one customer puts his/her order, the `JSON` file shall be locked in order to prevent collision and if it is locked, how can another customer put order at the exact same time? To solve this issue, and for test, I decided to have a folder in the server where every customer (who is going to put an order) can put his unique ID there (uploading a text file with the name of the customer's ID) and I just read that folder to see who has put any order and then I delete the file which was uploaded by the customer indicating he/she has just put an order to be ready from another order from that customer (every customer creates a folder with his/her unique ID name to put detailed list of his/her orders and this is handled by PHP code) It works fine but does not seem to be a true manner from performance point of view Any suggestion?

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            AndroidVH wrote:

            one `JSON` file in the `PHP` server to collect the orders from different customers

            Unlike an ASP or PHP page, a JSON file does not "collect" anything. Based on what you've provided, unless you are doing something totally wrong, there should be no way for it to become locked. If multiple clients request the same JSON file, the web server will deliver the file to each client without issue.

            AndroidVH wrote:

            Any suggestion?

            The whole "upload a file containing a customer number and/or order" approach seems way wrong to me. When you make contact with a web server, a one-on-one relationship has been established. When you interact with a web page (e.g., PHP file), you are doing so with your "copy" of it. If some other client is also interacting with that same page, again it's on their own "copy" of it. The web server keeps track of all those connections (up to some upper limit). Admittedly, I may be completely wrong on this. It borders on ecommerce which I have zero experience with. But what you are doing just seems kludgy and prone to error.

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

            A 1 Reply Last reply
            0
            • D David Crow

              AndroidVH wrote:

              one `JSON` file in the `PHP` server to collect the orders from different customers

              Unlike an ASP or PHP page, a JSON file does not "collect" anything. Based on what you've provided, unless you are doing something totally wrong, there should be no way for it to become locked. If multiple clients request the same JSON file, the web server will deliver the file to each client without issue.

              AndroidVH wrote:

              Any suggestion?

              The whole "upload a file containing a customer number and/or order" approach seems way wrong to me. When you make contact with a web server, a one-on-one relationship has been established. When you interact with a web page (e.g., PHP file), you are doing so with your "copy" of it. If some other client is also interacting with that same page, again it's on their own "copy" of it. The web server keeps track of all those connections (up to some upper limit). Admittedly, I may be completely wrong on this. It borders on ecommerce which I have zero experience with. But what you are doing just seems kludgy and prone to error.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

              A Offline
              A Offline
              AndroidVH
              wrote on last edited by
              #6

              Sorry, I meant the orders are stored in the JSON by PHP code I changed the process so as to prevent writing to the same file by different clients

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups