本文整理汇总了PHP中Mysql::getVar方法的典型用法代码示例。如果您正苦于以下问题:PHP Mysql::getVar方法的具体用法?PHP Mysql::getVar怎么用?PHP Mysql::getVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mysql
的用法示例。
在下文中一共展示了Mysql::getVar方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getList
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: getCateIdByMark
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: getList
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: getPostsCount
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: getList
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;
//.........这里部分代码省略.........