Hi,

not sure if this is the correct place to discuss plugins. I just
started using sfPropelFinderPlugin, which is very useful, thanks
Francois.

One feature which I needed was the ability to order by complex
expressions, rather than just column names. This ability is permitted
by using a round bracket in the column name (see
BasePeer::createSelectSql()). For example:

$c = new Criteria();
$c->addDescendingOrderByColumn('(IF person.id < 100, 1, 0)');

of course this example is not a real one, just a simplification to
help explain.

However, this didn't work with the finder, so I made a patch to allow
it, which is included at the end of this message.

What do you think? Would it be possible to incorporate this into the
plugin?

Thanks

David

Index: sfPropelFinder.php
===================================================================
--- sfPropelFinder.php  (revision 9503)
+++ sfPropelFinder.php  (working copy)
@@ -482,7 +482,16 @@
    */
   public function orderBy($columnName, $arguments = array())
   {
-    $column = $this->getColName($columnName);
+    // If the column name contains an open bracket, we assume that it
+    // contains a complex expression rather than a column name. See
+    // BasePeer::createSelectSql() for the origin of this hack.
+    if (strpos($columnName, '(') !== false) {
+      $column = $columnName;
+    }
+    else {
+      $column = $this->getColName($columnName);
+    }
+
     if(!is_array($arguments))
     {
       $arguments = func_get_args();

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to