Try this:

class YourModel extends AppModel {
  // ...

  function hasField($name) {
    if ($name === 'initial_monthly_payment') {
      return true;
    }
    return parent::hasField($name);
  }

  function beforeFilter($query) {
                if (!empty($query['order'])) {
                        foreach($query['order'] as $i => $a) {
                                if (!is_array($a)) {
                                        continue;
                                }
                                foreach($a as $k => $v) {
                                        $alias = $this->alias;
                                        $field = $k;
                                        if (strpos($field, '.') !== false) {
                                                list($alias, $field) = 
explode('.', $field, 2);
                                        }
                                        if ($alias == $this->alias && $field ==
'initial_monthly_payment') {
                                                $query['order'][$i] = 'RAND()';
                                        }
                                }
                        }
                        return $query;
                }
  }
}

hth
grigri

On Sep 10, 2:36 pm, Cosmin Paul <[email protected]> wrote:
> Because I use the query to mysql for some math.
> CakePhp dose't let me use
> $paginator->sort('Initial Monthly repayments','initial_monthly_payment');
> <CODE>
>    <php>
>     $initial_monthly_payment = MATH FORMULAS;
>   </php>.
>  <SQL FIELDS QUERY>
>     .
>     .
>     $initial_monthly_payment.'` as `initial_monthly_payment'
>     .
>     .
>  </SQL FIELDS QUERY>
> </CODE>
>
> I don't have 'initial_monthly_payment' as a field in the table.
>
> Haw can I fix this ?
>
> Thanks for the time!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to