2 Replies Latest reply on Oct 12, 2009 1:19 PM by SPGAnne

    PHP MySQL Flex - why isn't a new get of database reflecting a recent change

    SPGAnne Level 1

      I am new to PHP and MySQL.  I have been taking courses about all this on Lynda.com.  I have installed the WAMP test server on my system.


      I used the "Create Database From Application" wizard in Flex Buolder 3 to get me started.  This successfully generated the .php code for the CRUD access to my database.  When I try to run the .mxml application generated by the wizard it doesn't work( I get an error 1008 saying "The markup in the document following the root element must be well-formed").  I spent quite a bit of time trying to figure that out and gave up.  Then I tried just writing my own basic .mxml app to call the CRUD functions in the .php code (that had been generated by the wizard) by using the HTTPService and using the method .send(params).  This all works fine except for the following situation:


      First I call the "FindAll" php method which gets all my database records and displays them in a DataGrid control just fine.  Then I do an "Update" on a record, which also works fine (i.e. I get a result event that comes back showing the updated item has the new values, AND when I use phpMyAdmin on my WAMP server to double check, I can see the record has been updated fine on the server.)  Then I try doing a FindAll again, and I see in the Flex debugger that the result event coming back does NOT have my record with the update in it.  If I quit the Flex app and then launch it again and do a FindAll, the record I had updated is now correct and updated.


      Is there something I need to do to flush whatever is in local cache or something so that the .php code sends back a refreshed bunch of records.  Also, how does one go about debugging an app written in PHP and Flex?  The blog I saw here (http://www.adobe.com/devnet/flex/articles/flex_php.html) seems quite complex and references another PHP framework rather than using the PHP code generated by Flex.  I really want to do very simple stuff on the server side.  I just want to do basic CRUD on a database stored on the server to store the state of my Flex app and handle user sign in.  So I don't really want to become a PHP guru at this point.


      Thanks in advance to all the rest of you gurus who can help me out.

        • 1. Re: PHP MySQL Flex - why isn't a new get of database reflecting a recent change
          SPGAnne Level 1

          I found the reason for the error 1008 and fixed that problem.  It turns out the Create Database...wizard generates code which is deprecated.   I made changes in XMLSerializer.class.php, PEAR.php, Parser.php, Unserializer.php changing '&new' to 'new' where code was trying to instantiate something. In case you want to know,  I found this error by commenting out the gateway.resultFormat = "e4x" line in the mytableScripts.as file and then setting a breakpoint in the deserialize method and saw a bunch of deprecated error messages in the obj variable.  Even after fixing this, there still is a strange behavior in that when I try to update data in the first column (after the primary key column) of each record, I get an error saying 'No row found'.  (I can see this error is generated in the main .php script which is called by my HTTPService, but don't know why it thinks it can't find the row.  I am able to update other columns in that row and am also able to search by that first column.

          • 2. Re: PHP MySQL Flex - why isn't a new get of database reflecting a recent change
            SPGAnne Level 1

            Duh.  I found the reason my first column wasn't being updated and instead I was getting No row found.  (BTW I am leaving all this info here in case it is useful to some other Newbies trying all this for the first time.)  I found in the .php generated by the wizard that for the update() method it was first doing a SELECT for the record using the column I had specified to be the filter field (in this case it happens to be the first column after the key field column), instead of doing a SELECT on the primary key field.  So I corrected that in the php, and now I can update data in the first column.  Seems this Flex Builder wizard isn't bomb proof in how it works.  I guess the good news, is that all these bugs ARE forcing me to figure out all the details and learn php.