Archive for the 'MySQL Database' Category

My Adobe Flex / PHP Client / Server Articles on O’Reilly InsideRIA

Following are my six articles on DeveloperRIA on related to developing Adobe Flex clients using Adobe Flash Builder, which resource data from PHP Web application servers.

Using Flex 4 Clients with the PHP Zend Framework Server

Flex 4 / PHP Data-Centric Photo Transfers

Flex 4 / PHP Data-Centric Solutions

Photo Gallery Mate Framework, With Photo Caching

Processing AMF 3 PHP Server Object Arrays on the Flex Client Using Object Relational Mapping

AMF3 PHP Server Objects to Flex Client Object Relational Mapping

Note: if you plan to use the example code in my article Photo Gallery Maté Framework, With Photo Caching, then also be sure to read my article Flex 4 / PHP Data-Centric Photo Transfers.

Enjoy!

Pete

Flex 4 / PHP Data-Centric Photo Transfers Article

I used the WebORB for PHP Web application server, when I wrote the InsideRIA article titled Photo Gallery Mate Framework, With Photo Caching. The thrust of the article was about a photo gallery written in Flex 3. I had to modify the internals of the WebORB for PHP Web application server in order to make the Adobe Action Message Format 3 (AMF 3) photo data remote messaging transfer from the PHP server to the Flex client work properly.

The detailed and involved modifications of WebORB for PHP internals were part of the article along with a larger more involved set of “how to” information on my blog. Since publishing this article, I have replaced using WebORB for PHP Web application server with the Zend Framework Zend_Amf class for Adobe Action Message Format 3 (AMF 3) client / server messaging transfers. I accidentally discovered a way to transfer photo data using the PHP Zend_Amf class, which works without modification of the AMF 3 data streaming internal code. This is the first PHP centric AMF 3 based server that I am aware of where I did not have to modify the internal PHP code for server to Flex client photo data transfers.

I thought it best to share this information with by describing the problem, how you can easily work around it, show how you can use this information, and to provide a server side update to my Photo Gallery Mate Framework, With Photo Caching article.

I have another article about using the Zend Framework titled Flex 4 / PHP Data-Centric Solutions, which is worth reading too. I hope that this information helps you as it has for me by making PHP centric photo data transfers using AMF 3 messaging much more easy to perform than using WebORB for PHP.

PHP Data-Centric Solutions using Zend Framework

See my DevelopRIA article titled: Flex 4 / PHP Data-Centric Solutions I guarantee that you will learn something new in building Adobe Flex clients, which utilize PHP centric web application servers, by reading this article. Flash Builder provides server-side remoting technology supporting ASP.Net, J2EE, HTTP/REST and SOAP Web services, PHP, BlazeDS, ColdFusion, and LiveCycle Data Services for streaming data to and from a Flex 4 client. This article exclusively covers the PHP server-side remoting technology principally with Zend’s PHP Zend Framework web application server. New RIA client and PHP sever development opportunities are emerging using the newly released Flash Builder 4 (Flex 4) IDE linked the recent additions to the Zend Framework PHP Web application server for messaging via Adobe Message Format 3 (AMF 3) serial data streams.

DevelopRIA: Photo Gallery Maté Framework, With Photo Caching Article

My article titled Photo Gallery Maté Framework, With Photo Caching has just been published on  the DevelopRIA blog.

I have have been developing Adobe Flex-based RIA applications for nearly three years. My prominent need has been for capable RIA photo galleries. I observed over time that most Adobe Flex-based example photo galleries resourced photos—either locally or remotely—from photo files stashed in folders or folder hierarchy. There are better ways using Adobe Flex Builder to create RIA clients, what are driven from a photo database repository residing on a remote PHP Web application server.

The article’s example photo gallery is a worthwhile visit to better appreciate what my DevelopRIA article is all about. And if you mouse right-click in your Web browser, you can view the source code for this photo gallery. Visit the DevelopRIA article for the details of how this photo gallery client / server solution works along with a detailed analysis of core software code.

Noteworthy to this article is my adjunct blog note titled Adobe AMF 3 Transfer of Photo Data From a PHP Application Server To a Adobe Flex Client. This article expands on  issues with PHP string data types when when transferring photos from the Web application server to the Flex client.

If you need additional basic information related to developing and deploying Flex Builder to PHP application server, client / sever remoting, then see my two earlier InsideRIA blog articles on these topics:

Adobe AMF 3 Transfer of Photo Data From a PHP Application Server To a Adobe Flex Client

Author’s Update, June 1, 2010

This article describes how and why you need to modify the WebORB for PHP internal PHP code so that you can transfer photos from the PHP server to the Flex client, arriving as ActionScript 3 ByteArray data type. This internal PHP code modifications, described later in this article are no longer necessary. I recently identified a new way perform this photo data transfer by replacing the WebORB for PHP application server with Zend’s Zend Framework application server. Zend Framework supports photo data transfers without requiring internal code modification of PHP code within the framework. See my DevelopRIA article Flex 4 / PHP Data-Centric Photo Transfers for details on how to replace WebORB for PHP with Zend Framework.

________________________

Transferring photos from the PHP server to the Flex client via AMF 3 RemoteObject data streams is currently one of my favorite RIA topics. That’s because it took me more than a few days to figure out why I was able to display my photos when they were on the PHP server, but I could no longer display them by the time they were received by my Flex client. I’m anxious to share what I know about this in the hope that others do not have to go through what I did to get this working properly. The subtleties of what happens during the server-to-client photo data transfer are enough to drive you up the wall.

Here’s the scenario, what you’ll require and the specific solution that helped me.

In my SQGallery application article in DevelopRIA, we were discussing a Flex-based photo rendering RIA named SQGallery that pulls the photos from a MySQL database with Action Message Format (AMF3) Messaging through the WebORB for PHP application server. The dilemma is that the PHP data types are somewhat restricted in what’s available to meet our needs. Principally, the PHP data types are four scalar types: boolean, integer, float (floating-point number, a.k.a. ‘double’) and string; two compound types: array and object; and finally two special types: resource and NULL.

When the WebORB PHP application server loads photo data — effectively an array of bytes — from the SQPhoto MySQL database, PHP insists on typing photos as a string data type. Ah, I thought, all sounds well and good. I will simply return the photo PHP string photo byte array to the Flex client, receiving the photo data as an ActionScript 3 (AS3) String object. Then I will cast the String AS3 object to a ByteArray AS3 object so that the photo can be rendered and displayed using the Loader AS3 class.

The above is a great idea, but it did not work. I wondered why. After all, PHP strings are AS3 Strings … or are they? The AS3 String objects are formatted UTF-8, which means single-byte strings — the same as PHP server-side strings, right? You are wrong by 100%. In ActionScript, if the eighth bit (bit 7) of any byte is set (1), then the UTF-8 single byte is extended to a two-byte UTF-8 sequence. And guess what? Many of the photo string (array of bytes) have the eighth bit set. Talk about messing the photo content up! No wonder photos won’t display in the SQGallery Flex client.

Continue reading ‘Adobe AMF 3 Transfer of Photo Data From a PHP Application Server To a Adobe Flex Client’