switch($kk)
{
case 1:
$flag=true;
if ($month)
{
echo"<pre>";
echo $select->where('start_date between "' . $year . '-' . $month . '-01" and "' . $year . '-' . $month . '-' . $this->daysInMonth($month, $year).'" and end_date between "' . $year . '-' . $month . '-01" and "' . $year . '-' . $month . '-' . $this->daysInMonth($month, $year).'"' );
}
$select->order('start_date ASC');
break;
case 2:
$flag=true;
if ($month)
{
echo $select->where('start_date < "' . $year . '-' . $month . '-01" and end_date between "' . $year . '-' . $month . '-01" and "' . $year . '-' . $month . '-' . $this->daysInMonth($month, $year).'"' );
}
$select->order('start_date ASC');
break;
case 3:
$flag=true;
if ($month) {
echo $select->where('start_date between "' . $year . '-' . $month . '-01" and "' . $year . '-' . $month . '-' . $this->daysInMonth($month, $year).'" and end_date > "' . $year . '-' . $month . '-'.$this->daysInMonth($month, $year).'"' );
}
$select->order('start_date ASC');
break;
case 4:
$flag=true;
if ($month) {
echo $select->where('start_date < "' . $year . '-' . $month . '-01" and end_date > "' . $year . '-' . $month . '-'.$this->daysInMonth($month, $year).'"' );
}
$select->order('start_date ASC');
break;
}
$select->order('start_date ASC');
此语句对元素进行排序。但它根据查询案例的结果进行排序。我需要一个排序查询来排序所有案例结果。我该怎么办?
答案 0 :(得分:0)
你必须退出switch {}语句,它只在这种情况下执行什么。即使您将其置于默认值中:它也不会起作用,因为它可以单独处理案例或默认情况。我会在switch语句后创建一个条目。
验证您的switch case是否已执行,然后有另一个语句执行排序以应用于所有情况。