예제 #1
0
 public function getList($search)
 {
     $mysql = new Mysql();
     $PageSize = intval($search->PageSize);
     $FirstRow = intval($search->PageIndex - 1) * $PageSize;
     $sqlList = "select Subject,Url from project where (Status=6 or Status=7) and Type=" . intval($this->Type) . " order by Pv desc LIMIT {$FirstRow}, {$PageSize};";
     $sqlCount = "select count(Id) from project where (Status=6 or Status=7) and Type=" . intval($this->Type);
     $res = array();
     if ($search->NeedCount) {
         // 查找 count 和 数据
         $totalCount = $mysql->getVar($sqlCount);
         if (empty($totalCount)) {
             $res["Success"] = true;
             $res["Data"] = null;
             $res["Count"] = 0;
         } else {
             $res["Success"] = true;
             $res["Data"] = $mysql->getData($sqlList);
             $res["Count"] = $totalCount;
         }
     } else {
         // 只查找数据
         $res["Success"] = true;
         $res["Data"] = $mysql->getData($sqlList);
     }
     $mysql->closeDb();
     return $res;
 }
예제 #2
0
 function getCateIdByMark($mark)
 {
     $mysql = new Mysql();
     $sqlformat = "select Id from  %scategory%s where NameUrl='%s' and belong=%d limit 1";
     $sql = sprintf($sqlformat, $mysql->dbpre, $mysql->debug, $mysql->escape($mark), intval($this->Belong));
     $Id = $mysql->getVar($sql);
     $mysql->closeDb();
     //echo $sql;
     return $Id;
 }
예제 #3
0
 public function getList($search)
 {
     $mysql = new Mysql();
     $PageSize = intval($search->PageSize);
     $FirstRow = intval($search->PageIndex - 1) * $PageSize;
     $sqlList = "SELECT h.*,(SELECT Subject FROM " . $mysql->dbpre . "project" . $mysql->debug . " WHERE Id=h.ProjectId) AS Subject,u.Name,u.Ratio as UserRotio FROM " . $mysql->dbpre . "hours" . $mysql->debug . " as h," . $mysql->dbpre . "user" . $mysql->debug . " as u WHERE h.UserId=u.UserId";
     $sqlCount = "SELECT COUNT(Id) from " . $mysql->dbpre . "hours" . $mysql->debug . " where 1=1";
     if ($search->ProjectId > -1) {
         $sqlList .= " AND ProjectId= " . intval($search->ProjectId);
         $sqlCount .= " AND ProjectId= " . intval($search->ProjectId);
     }
     if ($search->Status > -1) {
         $sqlList .= " AND Status= " . intval($search->Status);
         $sqlCount .= " AND Status= " . intval($search->Status);
     }
     // var_dump( $sql );
     // exit;
     $sqlList .= " Order by id desc LIMIT {$FirstRow}, {$PageSize};";
     //var_dump( $sqlList );
     //var_dump( $sqlCount );
     // 		exit;
     $res = array();
     if ($search->NeedCount) {
         // 查找 count 和 数据
         $totalCount = $mysql->getVar($sqlCount);
         if (empty($totalCount)) {
             $res["Success"] = true;
             $res["Data"] = null;
             $res["Count"] = 0;
         } else {
             $res["Success"] = true;
             $res["Data"] = $mysql->getData($sqlList);
             //print_r($sqlList);
             $res["Count"] = $totalCount;
         }
         //$Res["Set"] = true;
     } else {
         // 只查找数据
         $res["Success"] = true;
         $res["Data"] = $mysql->getData($sqlList);
         //$res["Set"] = false;
     }
     $mysql->closeDb();
     // $Res["Sql"] = $Sql;
     // $Res["SqlCount"] = $SqlCount;
     return $res;
 }
예제 #4
0
 function getPostsCount($postSearch)
 {
     $mysql = new Mysql();
     //$postSearch=new PostSearch();
     $sql = "SELECT   COUNT(id) FROM " . $mysql->dbpre . "post" . $mysql->debug . " WHERE belong=" . intval($this->Belong);
     if ($postSearch->CategoryId != "") {
         $sql .= " and CategoryIds like '%," . $mysql->escape($postSearch->CategoryId) . ",%'";
     }
     if ($postSearch->CategoryRoot != -1) {
         $sql .= " and CategoryRoot = " . intval($postSearch->CategoryRoot);
     }
     if ($postSearch->Status != -1) {
         $sql .= " and Status = " . intval($postSearch->Status);
     }
     if ($postSearch->Keyword != "") {
         $sql .= " and (Subject like '%" . $mysql->escape($postSearch->Keyword) . "%' or content like '%" . $mysql->escape($postSearch->Keyword) . "%')";
     }
     if ($postSearch->Tag != "") {
         $sql .= " and tag like '%," . $mysql->escape($postSearch->Tag) . ",%'";
     }
     if ($postSearch->TimeStart != "" && $postSearch->TimeEnd != "") {
         $sql .= " and DisplayDate between '" . $mysql->escape($postSearch->TimeStart) . "' and '" . $mysql->escape($postSearch->TimeEnd) . "'";
     }
     if ($postSearch->LtOrder != -1) {
         $sql .= " and DisplayOrder < " . intval($postSearch->LtOrder);
     }
     if ($postSearch->GtOrder != -1) {
         $sql .= " and DisplayOrder > " . intval($postSearch->GtOrder);
     }
     //var_dump($sql);die;
     //echo $sql;
     $totalCount = $mysql->getVar($sql);
     if (!$totalCount) {
         $totalCount = 0;
     }
     $mysql->closeDb();
     return $totalCount;
 }
예제 #5
0
 function getList($search)
 {
     $mysql = new Mysql();
     $PageSize = intval($search->PageSize);
     $FirstRow = intval($search->PageIndex - 1) * $PageSize;
     $sqlList = "SELECT *,(SELECT name FROM user WHERE UserId=p.UserId) as Name from " . $mysql->dbpre . "project" . $mysql->debug . " as p where 1=1";
     $sqlCount = "SELECT COUNT(Id) from " . $mysql->dbpre . "project" . $mysql->debug . " where 1=1";
     if ($search->Type > -1) {
         $sqlList .= " AND Type= " . intval($search->Type);
         $sqlCount .= " AND Type= " . intval($search->Type);
     }
     if ($search->Department > -1) {
         $sqlList .= " AND Department= " . intval($search->Department);
         $sqlCount .= " AND Department= " . intval($search->Department);
     }
     if ($search->Team > -1) {
         $sqlList .= " AND Team= " . intval($search->Team);
         $sqlCount .= " AND Team= " . intval($search->Team);
     }
     if ($search->Status > 0) {
         if ($search->Status == 100) {
             $sqlList .= " AND Status<6";
             $sqlCount .= " AND Status<6";
         } else {
             if ($search->Status == 200) {
                 $sqlList .= " AND Status>5 AND Status<10";
                 $sqlCount .= " AND Status>5 AND Status<10";
             } else {
                 $sqlList .= " AND Status=" . intval($search->Status);
                 $sqlCount .= " AND Status=" . intval($search->Status);
             }
         }
     }
     if ($search->UserId > 0) {
         $sqlList .= " AND UserId= " . intval($search->UserId);
         $sqlCount .= " AND UserId =" . intval($search->UserId);
     }
     if ($search->Developer > 0) {
         $sqlList .= " AND ( Id in ( SELECT ProjectId FROM " . $mysql->dbpre . "hours" . $mysql->debug . " where UserId =" . intval($search->Developer) . ")";
         $sqlCount .= " AND ( Id in ( SELECT ProjectId FROM " . $mysql->dbpre . "hours" . $mysql->debug . " where UserId =" . intval($search->Developer) . ")";
         $sqlList .= " OR Id in ( SELECT ProjectId FROM " . $mysql->dbpre . "developer" . $mysql->debug . " where UserId =" . intval($search->Developer) . "))";
         $sqlCount .= " OR Id in ( SELECT ProjectId FROM " . $mysql->dbpre . "developer" . $mysql->debug . " where UserId =" . intval($search->Developer) . "))";
     }
     //	1按提交顺序(从先到后)2按上线时间(从近到远)3按总PV值(从高到低)4按推荐指数(从高到低)5按工时(从少到多)
     switch ($search->Order) {
         case 1:
             $sqlList .= " ORDER BY ID ASC";
             break;
         case 2:
             $sqlList .= " ORDER BY PublishTime DESC";
             break;
         case 3:
             $sqlList .= " ORDER BY PV DESC";
             break;
         case 4:
             $sqlList .= " ORDER BY LAUD DESC,PublishTime DESC";
             break;
         case 5:
             $sqlList .= " ORDER BY Hours ASC";
             break;
         default:
             if ($search->Status == 200) {
                 $sqlList .= " ORDER BY PublishTime DESC";
             } else {
                 if ($search->Status == 100) {
                     $sqlList .= " ORDER BY PublishTime ASC, CreateTime ASC";
                 } else {
                     $sqlList .= " ORDER BY Status ASC";
                 }
             }
             break;
     }
     $sqlList .= " LIMIT {$FirstRow}, {$PageSize};";
     //var_dump( $sqlList );
     //var_dump( $sqlCount );
     // 		exit;
     $res = array();
     if ($search->NeedCount) {
         // 查找 count 和 数据
         $totalCount = $mysql->getVar($sqlCount);
         if (empty($totalCount)) {
             $res["Success"] = true;
             $res["Data"] = null;
             $res["Count"] = 0;
         } else {
             $res["Success"] = true;
             $res["Data"] = $mysql->getData($sqlList);
             //print_r($sqlList);
             $res["Count"] = $totalCount;
         }
         //$Res["Set"] = true;
     } else {
         // 只查找数据
         $res["Success"] = true;
         $res["Data"] = $mysql->getData($sqlList);
         //$res["Set"] = false;
     }
     $mysql->closeDb();
     // $Res["Sql"] = $Sql;
     // $Res["SqlCount"] = $SqlCount;
     return $res;
 }