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

    +157

    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
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    /**
     * Получить список NEW5
     * 
     * @return array список событий
     */
    public function getLastForBlockNew($cat_tc_id = NULL)
    {
    
        $max_name_len = 41;
    
        $sql = "SELECT
                    a.d_id,
                    CONCAT(a.d_sname, ' ', a.d_name, ' ', a.d_fname) as d_name,
                    SUBSTR(a.d_description, 0, 30) as d_description,
                    a.d_rating,
                    c.c_name_url,
                    b.rg_name_url,
                    '".Application_Url_Maker::makeUrl(array(), 'sub-domain1')."' as domain
                FROM customers a
                    LEFT JOIN cities c ON c.c_id=a.d_c_id
                    LEFT JOIN regions b ON b.rg_id=c.c_rg_id
                WHERE a.d_rating is not NULL
                ORDER BY RAND()
                LIMIT 5
        ";
        $query[-1] = $this->querycached($sql);
    
        $sql = "SELECT
                    a.h_id,
                    a.h_name_ru,
                    SUBSTR(a.h_description, 0, 30) as h_description,
                    a.h_rating,
                    c.c_name_url,
                    b.rg_name_url,
                    '".Application_Url_Maker::makeUrl(array(), 'sub-domain2')."' as domain,
                    h_lat,
                    h_lon,
                    h_address,
                    h_phones,
                    d.hs_name_url
                FROM hospitals a
                    LEFT JOIN cities c ON c.c_id=a.h_c_id
                    LEFT JOIN regions b ON b.rg_id=c.c_rg_id
                    LEFT JOIN item_specializations d ON d.hs_id=a.h_hs_id
                WHERE a.h_rating is not NULL
                ORDER BY RAND()
                LIMIT 5
        ";
        $query[1] = $this->querycached($sql);
    
        $tc_ids = $this->db->fetchAll("select tc_id, tc_name_subdomain from type_catalogs where tc_id<>1");
        foreach($tc_ids as $v){
            $sql = "SELECT
                        a.cat_id,
                        a.cat_name_ru,
                        SUBSTR(a.cat_description, 0, 30) as cat_description,
                        a.cat_rating,
                        c.c_name_url,
                        b.rg_name_url,
                        '".Application_Url_Maker::makeUrl(array(), $v['tc_name_subdomain'])."' as domain,
                        cat_lat,
                        cat_lon,
                        cat_address,
                        cat_phones
            FROM catalogs a
                LEFT JOIN cities c ON c.c_id=a.cat_c_id
                LEFT JOIN regions b ON b.rg_id=c.c_rg_id
            WHERE a.cat_tc_id=? and a.cat_rating is not NULL
            ORDER BY RAND()
            LIMIT 5
            ";
            $query[$v['tc_id']] = $this->querycached($sql, array($v['tc_id']));
        }
    
        foreach($query as $k=>$v){
            foreach($v as $k1=>$v1){
                if(isset($v1['cat_name_ru']) && mb_strlen($v1['cat_name_ru']) > $max_name_len){
                    $query[$k][$k1]['cat_name_ru'] = mb_substr($v1['cat_name_ru'], 0, $max_name_len).'...';
                }
                elseif(isset($v1['h_name_ru']) && mb_strlen($v1['h_name_ru']) > $max_name_len){
                    $query[$k][$k1]['h_name_ru'] = mb_substr($v1['h_name_ru'], 0, $max_name_len).'...';
                }
            }
        }
        return $query;
    }

    Запостил: nergal, 26 Августа 2010

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

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