Skip to content

Commit

Permalink
Fixed issue: Sorting problem in MSSQL when browsing free text responses
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Nov 30, 2012
1 parent 7db126f commit 1ffa7c4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions application/controllers/admin/statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,20 @@ function listcolumn($surveyid, $column, $sortby="", $sortmethod="", $sorttype=""
}
}

if($sorttype=='N') {$sortby = "($sortby * 1)";} //Converts text sorting into numerical sorting
if($sortby != "") $search['order']=$sortby.' '.$sortmethod;
if ($sortby!='')
{
if ($sDBDriverName=='sqlsrv' || $sDBDriverName=='mssql')
{
$sortby="CAST(".Yii::app()->db->quoteColumnName($sortby)." as varchar)";
}
else
{
$sortby=Yii::app()->db->quoteColumnName($sortby);
}

if($sorttype=='N') {$sortby = "($sortby * 1)";} //Converts text sorting into numerical sorting
$search['order']=$sortby.' '.$sortmethod;
}
$results=Survey_dynamic::model($surveyid)->findAll($search);
$output=array();
foreach($results as $row) {
Expand Down

0 comments on commit 1ffa7c4

Please sign in to comment.