Exemple #1
0
 public static function total()
 {
     try {
         $num = _NONE;
         $sql = "select sum(visit_count) as num from countor where 1=1";
         Tool::logger(__METHOD__, __LINE__, sprintf("统计访问总数SQL: %s", $sql), _LOG_DEBUG);
         $conn = DBHelp::getConnection();
         $data = $conn->query($sql);
         if (!empty($data) && $data->num_rows > 0) {
             while ($row = $data->fetch_assoc()) {
                 $num = $row["num"];
                 break;
             }
         }
         DBHelp::close($conn);
         Tool::logger(__METHOD__, __LINE__, sprintf("统计访问总数%u.", $num), _LOG_DEBUG);
         return $num;
     } catch (Exception $e) {
         Tool::logger(__METHOD__, __LINE__, "统计访问总数失败:" . $e->getMessage());
         throw new Exception("统计访问总数失败:" . $e->getMessage());
     }
     return _NONE;
 }
Exemple #2
0
 public static function rcount($query)
 {
     try {
         $rcount = _NONE;
         $sql = "select count(1) as rcount from p_sort where 1=1";
         if (is_numeric($query->sortId) && $query->sortId > 0) {
             $sql = $sql . sprintf(" and sort_id=%u", $query->sortId);
         }
         if (strlen($query->sortName) > 0) {
             $sql = $sql . sprintf(" and p.sortName = ''", $query->sortName);
         }
         Tool::logger(__METHOD__, __LINE__, sprintf("查询产品类型总数SQL: %s", $sql), _LOG_DEBUG);
         $conn = DBHelp::getConnection();
         $data = $conn->query($sql);
         if (!empty($data) && $data->num_rows > 0) {
             while ($row = $data->fetch_assoc()) {
                 $rcount = $row["rcount"];
                 break;
             }
         }
         DBHelp::close($conn);
         Tool::logger(__METHOD__, __LINE__, sprintf("查询产品类型总数%u.", $rcount), _LOG_DEBUG);
         return $rcount;
     } catch (Exception $e) {
         Tool::logger(__METHOD__, __LINE__, "查询数据失败:" . $e->getMessage());
         throw new Exception("查询数据失败:" . $e->getMessage());
     }
     return _NONE;
 }
Exemple #3
0
 public static function rcount($query)
 {
     try {
         $rcount = _NONE;
         $sql = "select count(1) as rcount from doc_file where 1=1";
         if (is_numeric($query->fileId) && $query->fileId > 0) {
             $sql = $sql . sprintf(" and file_id=%u", $query->fileId);
         }
         if (strlen($query->inModule) > 0) {
             $sql = $sql . sprintf(" and in_module='%s'", $query->inModule);
         }
         if (strlen($query->fileKey) > 0) {
             $sql = $sql . sprintf(" and file_key='%s'", $query->fileKey);
         }
         if (strlen($query->savedPath) > 0) {
             $sql = $sql . sprintf(" and saved_path='%s'", $query->fileKey);
         }
         Tool::logger(__METHOD__, __LINE__, sprintf("查询图片总数SQL: %s", $sql), _LOG_DEBUG);
         $conn = DBHelp::getConnection();
         $data = $conn->query($sql);
         if (!empty($data) && $data->num_rows > 0) {
             while ($row = $data->fetch_assoc()) {
                 $rcount = $row["rcount"];
                 break;
             }
         }
         DBHelp::free($data);
         DBHelp::close($conn);
         Tool::logger(__METHOD__, __LINE__, sprintf("文件共%u条记录.", $rcount), _LOG_DEBUG);
         return $rcount;
     } catch (Exception $e) {
         Tool::logger(__METHOD__, __LINE__, "查询数据失败:" . $e->getMessage());
         throw $e;
     }
     return _NONE;
 }
Exemple #4
0
 public static function rcount($query)
 {
     try {
         $rcount = _NONE;
         $sql = "select count(1) as rcount from message where 1=1";
         Tool::logger(__METHOD__, __LINE__, sprintf("查询文本内容总数SQL: %s", $sql), _LOG_DEBUG);
         $conn = DBHelp::getConnection();
         $data = $conn->query($sql);
         if (!empty($data) && $data->num_rows > 0) {
             while ($row = $data->fetch_assoc()) {
                 $rcount = $row["rcount"];
                 break;
             }
         }
         DBHelp::close($conn);
         Tool::logger(__METHOD__, __LINE__, sprintf("查询文本内容 总%u.", $rcount), _LOG_DEBUG);
         return $rcount;
     } catch (Exception $e) {
         Tool::logger(__METHOD__, __LINE__, "查询数据失败:" . $e->getMessage());
         throw new Exception("查询数据失败:" . $e->getMessage());
     }
     return _NONE;
 }