jasonhinkle / phreeze

Phreeze Framework for PHP
http://phreeze.com/
GNU Lesser General Public License v2.1
377 stars 166 forks source link

Wrong SQL statement generated by Criteria.php with Order #133

Open alani1 opened 11 years ago

alani1 commented 11 years ago

Hi Jason !

I have a small issue around line 380 of Criteria.php in function Prepare(). In my case $filter->GetOrder($this) returns an empty string. What happens is that we have a , at the end of the order string e.g. "order by MyField desc," which at least mysql does not like. Would it make sense to change that line to :

$this->_order .= $filter->GetOrder($this) ? $orderDelim . $filter->GetOrder($this) : '';

Original code :

// if any of the filters have an order by then add those
    if (is_array($this->Filters)) {
        foreach ($this->Filters as $filter)
        {
            $orderDelim = $this->_order ? ',' : '';
            $this->_order .= $orderDelim . $filter->GetOrder($this);
        }
    }

This seems to solve the issue at least in my case.

regards,

Alain Alain

jasonhinkle commented 11 years ago

I actually just fixed that yesterday so if you update Phreeze that problem will be gone. (I created that bug and it was in the source code for a couple of days)