按价格排名的Codeigniter订单

时间:2019-10-15 02:57:24

标签: php codeigniter

我想将数据库中产品的价格从低到高排序,但是似乎出了点问题。我该如何解决这个问题?

我有一个价格表,如下。样本表

ID || kitap_id || Title || bot_fiyat
1       - 1  -   Title 1  - 4,90
2       - 1  -   Title 2  - 8,20
3       - 1  -   Title 3  - 8,90
4       - 1  -   Title 4  - 8,45
5       - 1  -   Title 5  - 8,11
6       - 1  -   Title 6  - 8,65

当我执行以下查询时,它会给我这样的结果:

    public function botdetay($id)
    {
        $id = clean_number($id);
        $this->db->where('kitap_id', $id);
        $this->db->order_by('CAST(bot_fiyat AS DECIMAL(10,2)) ASC');
        $query = $this->db->get('botlar');
        return $query->result();
    }

结果样本表

4,90
8,90
8,20
8,65
8,11
8,45

我想将价格从最低到最贵排序,但是我做错了。问题出在哪里?

1 个答案:

答案 0 :(得分:1)

非常简单,请尝试

// This is where you push to second screen from first screen
// Make sure you a method to get data from server
// And call that function when popped

Navigator.of(context).push(
     MaterialPageRoute(
           builder: (context) => SecondScreen())).then(
                (data){
                  if(data!=null && data){
                        getDataFromServer();  
                   });

// This is where you are poping from second screen.
// Pass a bool whether you want refresh first screen or not.
Navigator.of(context).pop(true)

这对您非常有帮助