YQL LogoAfter presenting on PHP, OAuth and Web Services (4th February 2009) it became apparent that the main killer technology was YQL. YQL for those unfamiliar with the acronym is Yahoo Query Language, a SQL like syntax that will let you query a whole host of data sources as if it were a database table.

Is YQL relevant to you? Well if you do any work with web services then definitely, it allows you to pull in multiple data sources, sort, transform, query your data points, to name but a few selling points. It will still be relevant to you if you are familiar with the SQL syntax, as it is actually really fun to play with using the console, especially if you take the provided example queries as a jump off point to tinker with. To demonstrate how easy we can make things, take a look at this example of a search query using this code.

YQL is now becoming even more powerful with a feature called ‘Open Tables’ which in essence instructs YQL on how to construct a web service URL. The power of this is that it enables you to interject values from other web service calls via sub selects. Some examples of Open Table definitions and example queries are being constructed at github.com/spullara/yql-tables.

During my talk I demonstrated a lot of the PHP code used to consume the results of the YQL calls which can be found over on my GitHub repository or you can browse my example scripts at http://carbonsilk.com/yql_php/.

To make development in PHP straightforward I used CodeIgniter for it’s MVC strengths and ease of installation. The beauty of using the framework with YQL and OAuth libraries doing the hard work behind the scenes is that you can write a few simple lines like the following to retrieve instant results:

// Controller method to allow us to access http://someurl.tld/yql_php/search_wikipedia/
function search_wikipedia($term = 'open')
    echo '<pre>';
    $yql_query = 'select * from xml where
            url="http://en.wikipedia.org/w/api.php?action=opensearch&search=' . $term . '&format=xml"
            and itemPath = "SearchSuggestion.Section.Item"';

The above code is the same query as could be found if you view in the provided console or view in my final project Search Wikipedia through YQL.

All I can say from doing this talk and looking deep into YQL is that there is a huge potential at our disposal here.