当前位置: 首页>>代码示例>>PHP>>正文


PHP STReview::count_all_comment方法代码示例

本文整理汇总了PHP中STReview::count_all_comment方法的典型用法代码示例。如果您正苦于以下问题:PHP STReview::count_all_comment方法的具体用法?PHP STReview::count_all_comment怎么用?PHP STReview::count_all_comment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在STReview的用法示例。


在下文中一共展示了STReview::count_all_comment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_info_by_post_type

 static function get_info_by_post_type($id, $post_type = null)
 {
     if (in_array($post_type, array("hotel", "hotels", "st_hotels"))) {
         $post_type = "st_hotel";
     }
     if (in_array($post_type, array("car", "cars", "st_car"))) {
         $post_type = "st_cars";
     }
     if (in_array($post_type, array("rental", "rentals", "st_rentals"))) {
         $post_type = "st_rental";
     }
     if (in_array($post_type, array("activity", "activities", "st_activity"))) {
         $post_type = "st_activity";
     }
     if (in_array($post_type, array("tour", "tours", "st_tour"))) {
         $post_type = "st_tours";
     }
     if (!$post_type) {
         return;
     }
     $location_meta_text = 'id_location';
     if ($post_type == 'st_rental') {
         $location_meta_text = 'location_id';
     }
     $location_id = get_the_ID();
     global $wpdb;
     $sql = "SELECT ID\r\n\t\t\t\tFROM `{$wpdb->postmeta}` \r\n\t\t\t\tJOIN `{$wpdb->posts}` \r\n\t\t\t\tON \t{$wpdb->posts}.ID = {$wpdb->postmeta}.post_id \r\n\t\t\t\t\tand {$wpdb->postmeta}.meta_key = '{$location_meta_text}' \r\n\t\t\t\t\tand {$wpdb->postmeta}.meta_value = '{$location_id}'\r\n\t\t\t\t\tand {$wpdb->posts}.post_status = 'publish'\r\n\t\t\t\t\tand {$wpdb->posts}.post_type = '{$post_type}'\r\n\t\t\t\tGROUP BY {$wpdb->posts}.ID";
     $results = $wpdb->get_results($sql, OBJECT);
     $num_rows = $wpdb->num_rows;
     // get review = count all comment number
     $comment_num = 0;
     foreach ($results as $row) {
         $comment_num = $comment_num + STReview::count_all_comment($row->ID);
     }
     wp_reset_query();
     return array('post_type' => $post_type, 'post_type_name' => self::get_post_type_name($post_type), 'reviews' => $comment_num, 'offers' => $num_rows, 'min_max_price' => self::get_min_max_price_location($post_type, $location_id));
 }
开发者ID:HatchForce,项目名称:bachtraveller,代码行数:37,代码来源:class.location.php

示例2: get_info_by_post_type

 static function get_info_by_post_type($id, $post_type = null, $list = NULL)
 {
     if (!$post_type) {
         return;
     }
     if (!in_array($post_type, array('st_activity', 'st_hotel', 'st_rental', 'st_cars', 'st_tours', 'st_holidays', 'hotel_room'))) {
         return;
     }
     $location_meta_text = 'id_location';
     if ($post_type == 'st_rental') {
         $location_meta_text = 'location_id';
     }
     $where = " (1= 1 )";
     $location_id = get_the_ID();
     if (!$list) {
         $list = TravelHelper::getLocationByParent($location_id);
     }
     if (is_array($list) and !empty($list)) {
         $where .= " AND (";
         $where_tmp = "";
         foreach ($list as $item) {
             if (empty($where_tmp)) {
                 $where_tmp .= "tb.multi_location LIKE '%_{$item}_%'";
             } else {
                 $where_tmp .= " OR tb.multi_location LIKE '%_{$item}_%'";
             }
         }
         $list = implode(',', $list);
         $where_tmp .= " OR tb.{$location_meta_text} IN ({$list})";
         $where .= $where_tmp . ")";
     } else {
         $where = "(tb.multi_location LIKE '%_{$location_id}_%' \r\n                        OR tb.{$location_meta_text} IN ('{$location_id}')) ";
     }
     $results = array();
     $num_rows = 0;
     global $wpdb;
     $table = $wpdb->prefix . $post_type;
     $join = " {$table} as tb ON  {$wpdb->posts}.ID = tb.post_id ";
     $join = self::edit_join_wpml($join, $post_type);
     $where = self::edit_where_wpml($where, $post_type);
     if (TravelHelper::checkTableDuplicate($post_type)) {
         $sql = "SELECT {$wpdb->posts}.ID\r\n                    FROM {$wpdb->posts} \r\n                    join {$join}              \r\n                    where {$where}\r\n                    GROUP BY {$wpdb->posts}.ID";
         //echo $sql ;
         $results = $wpdb->get_results($sql, ARRAY_A);
         $num_rows = $wpdb->num_rows;
         wp_reset_postdata();
     }
     // get review = count all comment number
     $comment_num = 0;
     if (is_array($results) and !empty($results)) {
         foreach ($results as $row) {
             $comment_num = $comment_num + STReview::count_all_comment($row['ID']);
         }
     }
     if ($num_rows > 1) {
         $name = self::get_post_type_name($post_type);
     } else {
         $name = self::get_post_type_name($post_type, true);
     }
     if ($list = TravelHelper::getLocationByParent(get_the_ID())) {
         $min_max_price = self::get_min_max_price_location($post_type, $list);
     } else {
         $min_max_price = self::get_min_max_price_location($post_type, $location_id);
     }
     return array('post_type' => $post_type, 'post_type_name' => $name, 'reviews' => $comment_num, 'offers' => $num_rows, 'min_max_price' => $min_max_price);
 }
开发者ID:DaddyFool,项目名称:travelTest,代码行数:66,代码来源:class.location.php


注:本文中的STReview::count_all_comment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。