1. PHP / Говнокод #7005

    +160

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    public function getList($sort) {
            if ($sort == 'id')
                $select = $this->select()->order('id ASC');            
            if ($sort == 'id2')
                $select = $this->select()->order('id DESC');
            if ($sort == 'username')
                $select = $this->select()->order('username ASC');
            if ($sort == 'username2')
                $select = $this->select()->order('username DESC');
            if ($sort == 'firstname')
                $select = $this->select()->order('firstname ASC');
            if ($sort == 'firstname2')
                $select = $this->select()->order('firstname DESC');
            if ($sort == 'lastname')
                $select = $this->select()->order('lastname ASC');
            if ($sort == 'lastname2')
                $select = $this->select()->order('lastname DESC');
            if ($sort == 'lastdate')
                $select = $this->select()->order('lastdate ASC');
            if ($sort == 'lastdate2')
                $select = $this->select()->order('lastdate DESC');
            if ($sort == 'regdate')
                $select = $this->select()->order('regdate ASC');
            if ($sort == 'regdate2')
                $select = $this->select()->order('regdate DESC');
            if ($sort == 'city')
                $select = $this->select()->order('city ASC');
            if ($sort == 'city2')
                $select = $this->select()->order('city DESC');
            if ($sort == 'vote')
                $select = $this->select()->order('vote ASC');
            if ($sort == 'vote2')
                $select = $this->select()->order('vote DESC');
            $result = $this->fetchAll($select);
            return $result;
        }

    Кусочек кода, написанный в классической манере "if-else" для Zend Framework

    Запостил: coderov, 20 Июня 2011

    Комментарии (16) RSS

    Добавить комментарий