Archive for the ‘php’ tag
Using Ext.Direct in Ajax applications
(This article was published on IBM developerWorks in October 2010)
The concept of Ajax has allowed web applications to evolve from being slow, unresponsive, and counter-intuitive to behaving more like desktop applications, delivering instant feedback, removing the need for page refreshes, and facilitating a much better user experience all around. The problem with Ajax is that it adds an additional layer of complexity to application development. In an event-driven application, you might perform an action when a user clicks on a button. In traditional application development, you can put all of your logic for what this action should do right in the event handler, but with Ajax it’s not that easy. You probably do some client-side validation, and if that is passed, you prepare your data and create a new Ajax request. You then define functions to handle a successful response and a failure. Then you must create the server-side code that will handle the Ajax requests and return a suitable response. This will probably need to be in a certain data format, such as JavaScript Object Notation (JSON) or XML, and you must provide it in such a way that the client side is expecting to receive it.
In short, Ajax development requires that a web application developer maintain a set of code both on the client side and on the server side, and there can be huge differences in how both work, making it difficult to debug and maintain. It would be great if developers had a way of calling server-side actions on the client-side, minimizing their exposure to all of the Ajax request and response handling. That’s where Ext.Direct comes in.
At first, Ext.Direct may seem like an overzealous solution to a small problem, but by investing your time and effort in it at the start, you’ll start to reap dividends later on. The initial hurdle of getting the building blocks of Ext.Direct working may seem complicated, but it typically only needs to be done once, and after that the changes needed to add new classes and methods are very straightforward. In this article, you learn how to get started and put the building blocks in place, and how to actually use Ext.Direct to call remote PHP methods from JavaScript. You then learn some of the more advanced features that Ext.Direct has to offer, and how to take full advantage of them in your own applications.
This article is available on IBM developerWorks in English and Japanese.
Alerts using XMPP/SMS
This tutorial is aimed at Web application developers who want to develop database-driven applications that are powered by an IBM DB2 pureXML database. The reader should be familiar with basic PHP code and be able to work with the Windows command prompt in order to follow the tutorial. Some experience with database management systems and the SQL language is also required. By the end of this tutorial, you will learn how to create object-oriented PHP Web applications that take advantage of a pureXML database.
Thanks to the native XML support that pureXML® offers IBM DB2® database developers, you can load XML data directly into your database, freeing up development time to add functionality to your application. Follow along in this tutorial to import an XML file with Euro foreign exchange rates into an IBM DB2 database and use special XQuery and SQL/XML functions to split this XML into separate database rows. You will also create a PHP script that pulls down new rates from the European Central Bank (ECB) Web site each day. Then you will extend the script to send update alerts to a Google Talk user using the XMPP protocol, and to a cell phone by SMS text message using the Clickatell SMS gateway service. Finally, you will create a PHP script that generates a PNG (Portable Network Graphics) graph of this data.
Read the tutorial at http://www.ibm.com/developerworks/xml/tutorials/x-alertxmpptut/
Knowledgebase using PHP
One of the most useful and versatile technologies available in IBM DB2 is its native support for XML data through the pureXML feature. PureXML allows you to store, retrieve, and manipulate XML data alongside and in the same manner as relational data. This enables you to develop applications that harness the advantages of both relational databases and XML data. Such applications can be particularly useful when you have a large amount of XML data that you need to leverage without having to first convert it into a relational structure.
This tutorial gives you step-by-step instructions on how to use PHP to create a Support Knowledge Base system that stores its data using a combination of traditional DB2 relational columns and pureXML columns. The application uses the power of SQL/XML to map XML data as a relational column. This allows you to use PHP to retrieve the data as though it were stored in a relational manner.
Creating applications that use a hybrid of relational data and XML data is easy thanks to the pureXML® feature of IBM® DB2® database servers. In this tutorial, you use PHP to create a Web application that connects to an IBM DB2 Express-C database and stores some of its data in traditional relational database columns, and some of it in native XML columns. You also learn how to use SQL/XML queries to retrieve, insert, update, and delete data from this database. Beyond the hands-on, project-based training, the tutorial equips you with the skills and conceptual knowledge you need to develop your own hybrid applications.
Read the article at http://www.ibm.com/developerworks/data/tutorials/dm-0911db2purexmlphp/
Leveraging pureXML, Part 3
In the third and final part of this series on creating applications that interact with an IBM DB2 pureXML database, you will use the popular PHP language to create scripts for publishing and syndicating the status updates in your database across the Web.
First you will allow users to create a Profile Badge in HTML, which permits them to generate a piece of HTML code to paste into their blog or Web site. This will pull the latest status updates from the pureXML database and present them in a pre-defined format. Users will be able to customize the design of the badge, choosing from a selection of sizes and color schemes, and define the number of updates to be displayed. Next, you will create a PHP script to publish the latest status updates in the database as an RSS Feed. Finally, you will create a script that presents all of the status updates in the database to the users with a Post to Twitter button alongside each update. When a user presses this button, the Twitter API will take the specified post and add the update to the Twitter stream of that user.
The pureXML® capabilities of IBM DB2® allow you to store XML natively in a database without modification, while Adobe® Flex® applications can read XML directly and populate Flex user interfaces. In this three-part article series, you will create a microblogging application that takes advantage of pureXML, Web services, and Adobe Flex; and even allows you to publish your microblogging updates on Twitter. In Part 1 of the series, you learned about Web Services and how they are enabled using DB2 pureXML as you created the microblog database and tested it. Part 2 tapped into Adobe Flex and ActionScript to create the user interface of your application. In this article, the final part of the series, you will learn how to use your pureXML Web Services to publish your microblog entries to an HTML page.
Read the article at http://www.ibm.com/developerworks/xml/library/x-db2mblog3/
Leveraging pureXML, Part 2
In Part 2 of my developerWorks article series on creating a microblogging service, I show you how to connect to the Web services created in Part 1 from a Flex application. This application allows you to post new updates to your microblog database and see a list of previous updates.
The pureXML® capabilities of IBM DB2® allow you to store XML natively in a database without modification, while Adobe® Flex® applications can read XML directly and populate Flex user interfaces. In this three-part article series, you will create a microblogging application that takes advantage of pureXML, Web services, and Adobe Flex; and even allows you to publish your microblogging updates on Twitter. In Part 1 of the series, you learned about Web Services and how they are enabled using DB2 pureXML as you created the microblog database and tested it. In this article, Part 2 of the series, you will tap into Adobe Flex and ActionScript® to create the user interface of the application.
Read the article at http://www.ibm.com/developerworks/xml/library/x-db2mblog2/