20 Replies Latest reply on Mar 11, 2014 1:23 PM by uboss84

    How to access data from MYSQL database

    PeteM71 Level 2

      All,

       

      I have a site that needs the client to update their own data.

      This has been done in a simple way using php and a mysql database.

       

      I now have a need for the client to enter some text which will be stored into the database.

      This is then displayed using a EDGE Animation.

       

      I can find examples on using JQUERY / PHP / JSON etc but nothing that convinces me this can really be done using MYSQL.

       

      Not being an expert on these things I was hoping that there might be a simple tutoiral somewhere that would give a hint on how to do this.


      Again, plenty of tutorials suggesting that it can be done but nobody seems to have proven this.

       

      Thanks for any tips


      Pete

        • 1. Re: How to access data from MYSQL database
          josh.dura Adobe Employee

          I personally haven't done anything like this, but in theory, you should be able to just create your animation and use filler text where you want the PHP/mySQL data to go. Then, when you take the animation into Dreamweaver, or whichever text editor you use, you would need to dig into the HTML/JS that Animate outputs, and replace the filler text with the outputted data from PHP/mySQL.

          • 2. Re: How to access data from MYSQL database
            PeteM71 Level 2

            Thanks for the reply, only just seen it.  That was what I was thinking - shame it cannot be done directly, would make it so much more useful.

            I am thinking of going down the text file route, even my user can update a text file (I think)...then use that to load in the text into the Animation.

             

            As said though there are plenty of "tips" on how to do this with JSON etc but nothing really useful - would be a great feature/tutorial.

             

            Thanks


            Pete

            • 3. Re: How to access data from MYSQL database
              elainecc Adobe Employee

              Hi, Pete-

               

              It's complicated, but you can use JSON to grab the data you  need and feed it into placeholder text.  It's not terribly hard to do, but it does require some knowledge of JSON.  I'll look into posting a tutorial at some point, but it might take a while...

               

              -Elaine

              • 5. Re: How to access data from MYSQL database
                PeteM71 Level 2

                Thanks - I have already seen ths and have been a follower of Lee's work for a number of years

                The tutorial does not cover how the Json files are "generated"!

                 

                These are not real world tutorials to me....I have a couple of ideas though.

                • 6. Re: How to access data from MYSQL database
                  shadowfax007 Level 1

                  Great topic and GREAT video tutorial!

                   

                  If you are familiar with PHP, Lasso, ASP, etc this should not be too difficult.  When I get a chance, I'll post a working example :-)

                   

                  As for creating the JSON files, this has nothing to do with Edge itself.  The files could be created with any scripting language.

                  Also, the same goes for using MySQL.  MySQL is the database that is connected to via Lasso, PHP, etc...

                  It does not connect directly to create a JSON file or import info into anything - it just stores your information - You need the other languages to get the info from MySQL into your Edge animation.

                   

                  For example, using whatever language (PHP, Lasso, Ruby, etc...), connect to your database (MySQL), gather the information you need, and write it to a file in a JSON format just like any other information you would write to a file.

                   

                  I use Lasso (http://www.lassosoft.com) as my language of choice but this may give you an idea of what to do in any other language:

                   

                  <?lassoscript

                   

                  //create MySQL call & get info

                                      var('prod_id') = 'xxx';

                   

                            var('sql_listings') = 'SELECT

                    prod_id,

                                                                                                  active,

                                                                                                  prod_photo_url,

                                                                                                  product_name,

                                                                                        FROM products

                                                                                        WHERE active = ""

                                                                                        AND prod_id >="' + $prod_id + '"

                                                                                        ORDER BY prod_id DESC';

                   

                            inline(

                                                -database=$db,

                    -username=$userName,

                                                -password=$passWrd,

                                                -sql=$sql_listings);

                   

                  //    create JSON formatted variable

                  records (loops returned records and adds them to a variable called result in a JSON formatted file);

                  $result += '

                  "\[

                            {

                                      \"image\" : \"images\/" + (field(\'prod_photo_url\') +

                                      "\"title\" : \" + (field(\'prod_photo_url\')

                            },  + '+ '\r\n';'

                  \]';

                  /records;

                   

                    var:'doc_name'='edge_import.txt',

                                        'path'='/path to file location/';

                       File_Create: $path + $doc_name, -FileOverwrite;

                      File_Write: $path + $doc_name, $result,-FileOverwrite;

                   

                    /inline;

                  ?>

                   

                  You only need to create ONE file and overwrite it each time.

                  The way servers work is this:

                  1. You request a file via your browser(http://www.yoursite.com/pagename.lasso)

                  2. That request is handed off to whatever language you use (pagename.lasso lets Apache know to send the page to Lasso first).

                  3. Lasso processes the request and creates the page in JSON format.

                  4. Lasso sends the page back to Apache and interprets the HTML code (including your animation).

                   

                  Because of this, the JSON file is created first each time BEFORE Edge runs...

                   

                  I hope that makes sense.  I haven't tried it yet (I just discovered an hour ago how to send info to a MySQL database from Edge!) but I will be testing it out soon and let you know!

                   

                  James

                  • 7. Re: How to access data from MYSQL database
                    resdesign Adobe Community Professional & MVP

                    Hey James, this is cool! I know nothing about lasso. I guess I have some reading to do!

                     

                    • 8. Re: How to access data from MYSQL database
                      shadowfax007 Level 1

                      redesign-

                       

                      I'm glad you liked it!

                       

                      I've been meaning to get into database connectivity with Edge (as a few already have!)

                      but it was actually your post on another similar thread with the download link to your email form in Edge that got me going. Once I saaw how easy it was to convert you code into something I could use to grab form info from within Edge and add it to a database (just a few hours ago!) I have been off and running! :-)

                       

                      As for Lasso ( http://www.lassosoft.com ), it is like any other language: PHP, ASP, Ruby, etc...

                      It started as  "Mac centric" software to connect FIleMaker to the web but has since become a robust language running on all major platforms and offering unparralled security and speed :-)

                       

                      Since my last post, I am in the process of workig on moving info back and forth from a MySQL database into Edge!  Again, thank you for the JSON link above!

                       

                      I wasn't looking forward to learning how to move data in and out of Edge but the developers actually made it quite simple as far as these thing go!!!

                       

                      I'm hoping to create a "mini" shopping cart using JSON and Edge and creating a video "tutorial" of the process for Edge users here (I've got a busy week so don't hold me to any timeframe!).  It will show from begining to end (of course with download files) how to do this.  I know it sounds daunting to many but it really isn't-believe it or not, my experience with JSON is that I've heard of it and know "kind of" what it does and yet I was able to create an "on the fly" JSON page with database info and upload it into Edge  within an hour after watching the video link you posted above!

                       

                      James

                      • 9. Re: How to access data from MYSQL database
                        jpbond13 Level 1

                        thanks for theses informations. I know now how to import data dynamicaly from a json file.

                        But if i need to use data from a MySQL database, with PHP, is there a way to do it without using a json file ?

                        Because i'm quite sure i can generate a json file in PHP, but if i can take a shortcut and call data directly in the database, it would be easier... any tutorial about that ?

                        really thanks for your help

                        • 10. Re: How to access data from MYSQL database
                          jpbond13 Level 1

                          no one can help me with this ?

                          • 11. Re: How to access data from MYSQL database
                            resdesign Adobe Community Professional & MVP

                            There are several threads here about the subject.

                            Check this one and several others by the same user:

                            http://forums.adobe.com/message/5285751#5285751

                            • 12. Re: How to access data from MYSQL database
                              jpbond13 Level 1

                              yes, i've already read it but thanks.

                              but as usual, he used a json file again...

                              it seems to have no way to communicate between Edge and a database without generate a json file in php or others languages then

                              Same problems we used to have with Flash...

                              I am disappointed...

                              • 13. Re: How to access data from MYSQL database
                                resdesign Adobe Community Professional & MVP

                                Check this out:

                                http://www.youtube.com/watch?v=Wwb6TFTx3sc

                                I did not watch it but it may be relevant to your situation.

                                • 14. Re: How to access data from MYSQL database
                                  PeteM71 Level 2

                                  - I'm confused  - jpbond13 clearly wants to connect to a database WITHOUT using a Json file and yet all the information has been to do with using a Json file...

                                  The reason I am saying this is because I am also looking for a way to connect to a database WITHOUT a Json file...

                                  • 15. Re: How to access data from MYSQL database
                                    resdesign Adobe Community Professional & MVP

                                    I am like you. I just watched it and the title is misleading!

                                    • 16. Re: How to access data from MYSQL database
                                      jpbond13 Level 1

                                      yes again, thanks PeteM71...

                                      As we used to do with Flash, Actionscript and database, because it was not possible to communicate natively between them, we used to create a xml file (with php or others...) with the data in it, and Flash read the xml file.

                                      10 years later, other soft (edge) but same process, with json and not xml...

                                      That's why not so much Flash dynamic websites exist...

                                      ...and why i will forget about using edge in my development for the moment...

                                      • 17. Re: How to access data from MYSQL database
                                        Jerry Witt Level 2

                                        Maybe this isn'r a bug, but a feature? EA ultimatly creates a set of HTML, CSS and js files that can all be easily read. So granting direct access to the mySQL database from them does not seem like a good idea. Reading and writing a JSON file at least adds a layer abstraction from direct access to the database.

                                         

                                        I would say the closest I've seen anyone come to pulling live, dynamic, data into the Edge Animate timeline is the Edge Suite tool for Drupal and Wordpress. With that, someone can use a CMS to manage and select content and build query lists. It has a feature to allow "data injection" into the EA files. Although at the end of the day, I think it is still creating a JSON file for the data injection.

                                        • 18. Re: How to access data from MYSQL database
                                          Preran Adobe Employee

                                          Hi jpbond 13,

                                           

                                          This is the answer I received from the product team:

                                           

                                          You can add a jQuery SQL plug in by loading the library dynamically within the project.  There are a couple of ways to do that:

                                           

                                          Thanks,

                                          Preran

                                          • 19. Re: How to access data from MYSQL database
                                            jpbond13 Level 1

                                            thanks Preran but it's not a solution, it's a sham !

                                            and same problems appear in Edge Reflow CC

                                            read my new tread : http://forums.adobe.com/thread/1321123

                                            • 20. Re: How to access data from MYSQL database
                                              uboss84 Level 1

                                              I have solve the  problem using php and mysql db...you can update the db throught a form in php and you can see the result in edge animate site...in this day i create a short guide