-1
        $field=$userVo->field;
        $order=$userVo->order;

    $selectQry      =   $this->_util->db->select()->from(array('M'=>$this->_name))
                            ->join(array('MX'=>TBL_MEDICATIONS_XREF),
                            'M.medication_id = MX.medication_id')
                            ->join(array('U'=>TBL_USERS),
                            'U.user_id = MX.user_id',array('U.identifier','U.email','U.mobile_number','U.first_name','U.last_name'))
                            ->where('MX.user_id = ?',mysql_escape_string($userId));

            if (!empty($field) && !empty($order))
            {
                // if(($field=="notes") || ($field=="rx_number"))
                if($field=="rx_number") 
                $selectQry->order("MX.$field  $order"); 

                if($field=="nick_name")
                $selectQry->order("M.$field  $order");


            } 

$medications        =   $this->_util->db->fetchAll($selectQry);

if($field=="rx_number")条件不行,是什么原因?

4

1 回答 1

1
           if($field=="rx_number") 
            $selectQry->order("MX.$field  $order"); 

          if($field=="nick_name")
            $selectQry->order("M.$field  $order");

安装它,你必须这样写。

          if($field=="rx_number") 
          {
            $orderfield = "MX.".$field." ".$order; 
            $selectQry->order($orderfield); 
          }

          if($field=="nick_name")
          {
            $orderfield2 = "M.".$field." ".$order;
            $selectQry->order($orderfiled2);
          }
于 2012-10-18T05:03:49.853 回答