 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Chris Hartjes' Blog: Sorting Relationship Results In Doctrine 1.2
by Chris Cornutt February 05, 2010 @ 10:51:32
Doctrine allows you to set up relationships to link data in various tables together. Unfortunately, those aren't always in the order they need to be in. In a new post to his blog Chris Hartjes shows you how to sort these relationship results just by adding a simple line to your request.
I started digging around via search engine. Took me about an hour to find the solution. First, it took me half the time to dive deep enough to find out WHERE I can define the default sort order. Surprisingly, it was in an area that made total sense but I could not find before.
You can see an example of it in the "hasMany" call in his code snippet - the addition of the "orderBy" option and the value showing the sorting order. Here's the StackOverflow page that gave him the answer he needed.
voice your opinion now!
relationship doctrine sort tutorial orderby
Zend Developer Zone: Paging and Sorting Data with Zend Framework, Doctrine and PEAR (part 2)
by Chris Cornutt January 04, 2010 @ 11:52:33
The Zend Developer Zone has posted the second part of their look at pagination with the combination of the Zend Framework, Doctrine and PEAR and how the Zend_Paginator component compares to the PEAR and Doctrine alternatives.
In the previous segment of this article, I introduced you to the Zend_Paginator class, which provides a flexible API for paginating any data collection, whether it is expressed as an array or a database result set. [...] This article will explore two such alternatives, the PEAR Pager class and the Doctrine Pager class, and give you a crash course in how you can use them to quickly add paging and sorting features to your PHP application.
The article gives examples for both of the other methods - a simple pagination of database information with the PEAR pager component (and other packages that can make the results more effective) and the creation of a Doctrine instance where the results are handled via a series of built-in method calls.
voice your opinion now!
tutorial zendframework pear doctrine pagination sort
PHPFreaks.com: PHP Custom List Order
by Chris Cornutt December 04, 2008 @ 16:00:07
The PHPFreaks site has a new tutorial posted today showing how to create a method for custom list ordering in PHP.
So you have some tabular data printed out in your browser. You can even change the order of the information by clicking on the column name at the top of your list. But can you make your own custom list order? Or maybe you're deciding to make a content management system (CMS). You're making your features modular, so it's easier to add/remove modules. How do you go about displaying them in a custom order in the browser?
They create some MySQL tables to store the data in and set off into the code. The sorting allows for the data to be ordered by any column in either ascending or descending order based on the users' clicks. The results are output in a standard HTML table.
voice your opinion now!
tutorial custom list sort ascending descending
Lee Blue's Blog: How To Sort A Zend_Db_Table_Rowset
by Chris Cornutt February 14, 2008 @ 17:11:00
Lee Blue has posted a handy tip for users of the Zend Framework, specifically when sorting the results from a query to tables linked in a Zend_Db_Table setup.
So you figured out how to define the relationships between your Zend_Db_Tables and you have issued a call to findDependentRowset(). You get your Rowset back but you need to sort the results by one of the columns in the dependent table. How do you do that?
Unfortunately, he's found out that you just simply can't - well, not without a custom function (until the 1.5 release of the framework rolls around). He shows his table set up and some sample database classes to relate to the tables (and link between them). The magic comes in with his DU_Utils class that takes in the data and sorts it based on the given column name in the given direction.
voice your opinion now!
zendframework zenddb table relationship sort order column
LivePipe Blog: Complex Sorting with PHP
by Chris Cornutt June 28, 2007 @ 07:11:21
On the LivePipe blog today, there's a quick new article demonstrating a sorting method that can be used for more than just simple datasources:
Most often when I need to sort complex data sets, I'm using some sort of SQL backend. Today I needed to do complex sorting of Reflection objects for some auto generating documentation I'm working on for the upcoming Picora release. [...] In the usort() examples, I had always been under the assumption that the return values had to be 0, 1 or -1. Today I learned that is not true at all, and you can come up with your own scoring system with any range, negative or positive.
He illustrates the point with a simple example showing the sorting of the documentation for Picora. In his protected function, scoreFromMethod, he defines the return array with several values instead of just the one.
voice your opinion now!
complex sort usort example picora complex sort usort example picora
|
Community Events
Don't see your event here? Let us know!
|