Combining the power of PHPLinq, Zend_Db, XML and arrays

      Comments Off on Combining the power of PHPLinq, Zend_Db, XML and arrays

PHPLinq is a class library for PHP, based on the idea of Microsoft's LINQ technology. LINQ is short for language integrated query, a component in the .NET framework which enables you to perform queries on a variety of data sources like arrays, XML, SQL server, … These queries are defined using a syntax which is very similar to SQL.

Using PHPLinq, the same functionality is created in PHP. Since regular LINQ applies to enumerators, SQL, datasets, XML, …, I decided PHPLinq should provide the same infrastructure. Here's an example PHPLinq query, which retrieves all names with a length less than 5 from an array of strings:

Notice the in()-function? This is basically a clue for PHPLinq to determine how t query data. In this case, PHPLinq will work with a string array, but is perfectly possible to hint PHPLinq with a database table, for example.

In the same way as the array is queried, a Zend_Db_Table or XML data source can be queried by using the exact same syntax. No SQL involved, just "plain old" PHP functions.

More information on Maarten Balliauw's blog.