19 Replies Latest reply on Nov 24, 2009 12:40 PM by sudhirm-rRcgag

    Data Service - only returning 256 chars on text field

    MartyO Level 1

      Using FlashBuilder Data Services - PHP service all working fine.

       

      Except the service is only returning the first 256 chars of a "text" field of my db table.

       

      The field has more than 256 chars and is marked up via the RTE component


      <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="14" COLOR="#000000" LETTERSPACING="0" etc...


      The generated code looks like(memberservice.php)

       

      public function getAllMember_content() {

       

              $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename" );       

      etc....

       

      Have tried a few conversions on the sql statement to no avail

       

      select *, convert(text,data) as data from members

      Any ideas on why this is happening - debugged in charles and its cut off in the response from ZEND/PHP so it in not Flex doing it

      this one is killing me :-)


      rgds
      m
        • 1. Re: Data Service - only returning 256 chars on text field
          David_F57 Level 5

          Hi,

           

          If you are using tinytext field that may be an issue (zend doesn't handle tinytext correctly- according to zend its the php at fault not their crappy product). This is the only thing I can think of without knowing more about your structures or your services.

           

          David.

          • 2. Re: Data Service - only returning 256 chars on text field
            MartyO Level 1

            Data-type is "Text" - also tried longtext, mediumtext

            • 3. Re: Data Service - only returning 256 chars on text field
              mewk Level 3

              it sounds like you're not exactly sure where the breakdown is occurring (it might be the service, it might be the SQL). so you need to narrow the possibilities.

              1. mysql -- run "SELECT (data) FROM ?? WHERE id='??'" in your favorite program (phpmyadmin, mysql command line, whatever).
              2. php -- copy the code from your generated php class (you'll need the constructor and class method), modify as needed (maybe you want to echo the result or print_r instead of a return), then call the method from your test file (you may need to supply the arguments for your method call).
              3. flex service call -- check the network monitor, the raw view should allow you to see the return data.
              4. somewhere else in the flex code -- place a breakpoint w/in your result handler and check the data there.

               

              i wouldn't do it exactly like this or necessarily in this order; some things are quicker to check first and using logging or other debugging methods might be a good idea, but would take much longer to write out. hopefully though this will be enough. best o luck,

               

              - e

              1 person found this helpful
              • 4. Re: Data Service - only returning 256 chars on text field
                David_F57 Level 5

                Hi,

                 

                Tommorrow when I get a chance I'll try a test using the old way (amfphp) and see what happens there. I dont recall having truncation issues but then again i don't use text fields that often.

                 

                You could try a varchar (set it say at 2000) and see what gets returned. Also have you done some traces on returned object lengths to see if the data is actually coming back at least that way you will know if its server end or client end.

                 

                David

                • 5. Re: Data Service - only returning 256 chars on text field
                  mewk Level 3

                  hmmm, you also have a number of fields capped at 256 characters. make sure you're not inadvertently mixing up your variables. maybe increase all the varchar fields to 300 and see if it has an effect.

                   

                  - e

                  • 6. Re: Data Service - only returning 256 chars on text field
                    Gaurav P(Adobe) Level 2

                    I tried using a column of type "text" in mysql with 480 characters in a row. It returns perfectly with the sample db code generated using flashbuilder.

                    Seems like there is some configuration on your mysql server side which is truncating the response.

                    1 person found this helpful
                    • 7. Re: Data Service - only returning 256 chars on text field
                      MartyO Level 1

                      thanks all for the suggestions

                       

                      still no joy - FlashBuilder beta 2 is only pulling 256 chars from the generated service...

                       

                      data=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vitae nisl quis enim adipiscing porttitor. Nam non dui non tortor elementum eleifend ut eget nulla. Phasellus mattis lorem tristique dui elementum dapibus. Pellentesque neque ligula, congue in sag

                       

                      no matter what I change the varchar lenght to - it still cuts it off. same as TEXT

                       

                      I think it is the PHP service - I have another DB on the same mysql that has no prbs pulling all the chars from a TEXT col.

                       

                      Will try rolling back to FB beta 1 to see if the generated code does the same thing

                       

                      this is getting very tiring Adobe!!!!!!!

                      • 8. Re: Data Service - only returning 256 chars on text field
                        Gaurav P(Adobe) Level 2

                        Can you please share the sample php service file and the sample database, which is causing this issue.

                         

                        Thanks,

                        - Gaurav

                        • 9. Re: Data Service - only returning 256 chars on text field
                          MartyO Level 1

                          much appreciated Gaurav

                           

                          I have attached the generated service code and a dump of the table.

                           

                          will keep trying my end

                           

                          rgds

                          m

                          • 10. Re: Data Service - only returning 256 chars on text field
                            MartyO Level 1

                            not sure what that upload did not work - trying a .zip file

                            • 11. Re: Data Service - only returning 256 chars on text field
                              mewk Level 3

                              hey MartyO,

                               

                              I cannot reproduce the error. Using the resource you provided, I created a flex app, threw in a DataGrid, and bound it to

                              membercontentService.getAllMember_content();
                              

                              Attached below is a screen shot of the app. If you need more input you're going to have to provide some more details, because the problem is not with what you've provided... sorry!!!

                               

                              - e

                              • 12. Re: Data Service - only returning 256 chars on text field
                                MartyO Level 1

                                wow thanks guys

                                 

                                can you send me the files back and I will run and debug? - this is very strange indeed

                                 

                                rgds

                                martin

                                • 13. Re: Data Service - only returning 256 chars on text field
                                  MartyO Level 1

                                  some enviroment details may help - I'm running....

                                   

                                  on Windows 7

                                   

                                  Zend Server - Version - 4.0.5 - Build Zend-Server-CE-5.3.0-Windows_x86

                                  PHP - Version 5.3.0

                                   

                                  MySQL - 5.1.36

                                  Apache/2.2.12 (Win32) mod_ssl/2.2.12 OpenSSL/0.9.8k

                                  Zend Framework Version    1.9.0

                                   

                                  rgds

                                  m

                                  • 14. Re: Data Service - only returning 256 chars on text field
                                    mewk Level 3

                                    sure, the fxp file is given below. also a few more ideas to keep in mind:

                                    • using ZendAMF
                                    • i configured a return type (shouldn't matter, but...)
                                    • might be easier to create a new app and generate your own service classes. if you know how to reconfigure the service class, that's fine. just be aware that the classes are geared for my local config.
                                    • in the sql table, why use varchar for an id?? db indexes much faster on ints...
                                    • if this doesn't work you should really consider reinstalling the zend framework.

                                    hopefully though, something will come of this!!

                                     

                                    - e

                                    • 15. Re: Data Service - only returning 256 chars on text field
                                      MartyO Level 1

                                      mewk - awesome :-)

                                       

                                      importing that FXP into the default workspace works - but it can't see the service

                                       

                                      What did I do wrong?

                                      • 16. Re: Data Service - only returning 256 chars on text field
                                        mewk Level 3

                                        Yes, well of course there is additional setup on your end that I have no control of when you import the fxp on your side. You need to create a new folder in your webroot and then configure the project properties to point to this path (right-click project properties >> Flex Server >> web root: C:\xampp\htdocs\testingmartyo, root url: http://localhost/testingmartyo/, the output folder C:\xampp\htdocs\testingmartyo\Test999995-debug).

                                         

                                        Then you need to add the php service, I created: C:\xampp\htdocs\testingmartyo\services\MembercontentService.php and then you need to make sure ZendAMF is accessible, there are many ways to do this, easiest t explain here is to simply paste the ZendFramework folder into C:\xampp\htdocs\testingmartyo\

                                         

                                        I don't know if all this will work, it's just configuring the setup and you can do this in a number of different ways. This is what I used. Like I wrote previously, it might be easier to create your own services and let the DCD wizard take care of the details.

                                         

                                        - e

                                        • 17. Re: Data Service - only returning 256 chars on text field
                                          MartyO Level 1

                                          ok solved - kind of

                                           

                                          phew - it's the generated service code it appears - not sure why it's working for some and not others! head scratching

                                           

                                          this works

                                           


                                          public function getAllItems() {
                                              $this->connect();
                                              $sql = "SELECT * FROM member_content";
                                              $result = mysql_query($sql) or die('Query failed: ' . mysql_error());
                                              return $result;
                                            }

                                           

                                          this does not

                                           

                                          public function getAllMember_content() {

                                           

                                                  $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename" );       
                                                  $this->throwExceptionOnError();
                                                 
                                                  mysqli_stmt_execute($stmt);
                                                  $this->throwExceptionOnError();
                                                 
                                                  $rows = array();
                                                 
                                                  mysqli_stmt_bind_result($stmt, $row->id, $row->title, $row->topic, $row->type, $row->data, $row->shortdesc, $row->date_created, $row->date_lastmod, $row->rank, $row->createdby, $row->content_source);
                                                 
                                                  while (mysqli_stmt_fetch($stmt)) {
                                                    $rows[] = $row;
                                                    $row = new stdClass();
                                                    mysqli_stmt_bind_result($stmt, $row->id, $row->title, $row->topic, $row->type, $row->data, $row->shortdesc, $row->date_created, $row->date_lastmod, $row->rank, $row->createdby, $row->content_source);
                                                  }
                                                 
                                                  mysqli_stmt_free_result($stmt);
                                                  mysqli_close($this->connection);
                                             
                                                  return $rows;
                                              }

                                           

                                           

                                           

                                          thanks all for your help

                                           

                                           

                                          many thanks

                                          martin

                                          • 18. Re: Data Service - only returning 256 chars on text field
                                            mewk Level 3

                                            MartyO, that is very strange and worth filing a bug report. Glad you figured it out though

                                             

                                            - e

                                            • 19. Re: Data Service - only returning 256 chars on text field
                                              sudhirm-rRcgag Adobe Employee

                                              This issue is because of mysqli related bug in php, while using prepared statement.

                                              There is already a bug logged with php. For details, please refer to http://bugs.php.net/bug.php?id=50021

                                               

                                              Thanks,

                                              Sudhir