本文整理汇总了PHP中CGroup::PrepareSql方法的典型用法代码示例。如果您正苦于以下问题:PHP CGroup::PrepareSql方法的具体用法?PHP CGroup::PrepareSql怎么用?PHP CGroup::PrepareSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGroup
的用法示例。
在下文中一共展示了CGroup::PrepareSql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetList
function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "USER_ID", "SOCSERV_USER_ID", "PROVIDER", "MESSAGE", "INSERT_DATE", "SUCCES_SENT");
}
$arFields = array("ID" => array("FIELD" => "SM.ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "SM.USER_ID", "TYPE" => "int"), "SOCSERV_USER_ID" => array("FIELD" => "SM.SOCSERV_USER_ID", "TYPE" => "int"), "PROVIDER" => array("FIELD" => "SM.PROVIDER", "TYPE" => "string"), "MESSAGE" => array("FIELD" => "SM.MESSAGE", "TYPE" => "string"), "INSERT_DATE" => array("FIELD" => "SM.INSERT_DATE", "TYPE" => "datetime"), "SUCCES_SENT" => array("FIELD" => "SM.SUCCES_SENT", "TYPE" => "char"));
$arSqls = CGroup::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_socialservices_message SM " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return false;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_socialservices_message SM " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_socialservices_message SM " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) > 0) {
$strSql = $DB->TopSql($strSql, $arNavStartParams["nTopCount"]);
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例2: GetListEx
public static function GetListEx($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "TIMESTAMP_X", "ACTIVE", "C_SORT", "ANONYMOUS", "NAME", "DESCRIPTION");
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "G.ID", "TYPE" => "int"), "TIMESTAMP_X" => array("FIELD" => "G.TIMESTAMP_X", "TYPE" => "datetime"), "ACTIVE" => array("FIELD" => "G.ACTIVE", "TYPE" => "char"), "C_SORT" => array("FIELD" => "G.C_SORT", "TYPE" => "int"), "ANONYMOUS" => array("FIELD" => "G.ANONYMOUS", "TYPE" => "char"), "NAME" => array("FIELD" => "G.NAME", "TYPE" => "string"), "STRING_ID" => array("FIELD" => "G.STRING_ID", "TYPE" => "string"), "DESCRIPTION" => array("FIELD" => "G.DESCRIPTION", "TYPE" => "string"), "USER_USER_ID" => array("FIELD" => "UG.USER_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_user_group UG ON (G.ID = UG.GROUP_ID)"), "USER_GROUP_ID" => array("FIELD" => "UG.GROUP_ID", "TYPE" => "string", "FROM" => "INNER JOIN b_user_group UG ON (G.ID = UG.GROUP_ID)"), "USER_DATE_ACTIVE_FROM" => array("FIELD" => "UG.DATE_ACTIVE_FROM", "TYPE" => "datetime", "FROM" => "INNER JOIN b_user_group UG ON (G.ID = UG.GROUP_ID)"), "USER_DATE_ACTIVE_TO" => array("FIELD" => "UG.DATE_ACTIVE_TO", "TYPE" => "datetime", "FROM" => "INNER JOIN b_user_group UG ON (G.ID = UG.GROUP_ID)"));
// <-- FIELDS
$arSqls = CGroup::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "DISTINCT", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_group G " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_group G " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_group G " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql_tmp);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// ТОЛЬКО ДЛЯ MYSQL!!! ДЛЯ ORACLE ДРУГОЙ КОД
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . intval($arNavStartParams["nTopCount"]);
}
$dbRes = $DB->Query($strSql);
}
return $dbRes;
}
示例3: GetList
function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "LOGIN", "NAME", "LAST_NAME", "EMAIL", "PERSONAL_PHOTO", "EXTERNAL_AUTH_ID", "USER_ID", "XML_ID", "CAN_DELETE", "PERSONAL_WWW");
}
$arFields = array("ID" => array("FIELD" => "SU.ID", "TYPE" => "int"), "LOGIN" => array("FIELD" => "SU.LOGIN", "TYPE" => "string"), "NAME" => array("FIELD" => "SU.NAME", "TYPE" => "string"), "LAST_NAME" => array("FIELD" => "SU.LAST_NAME", "TYPE" => "string"), "EMAIL" => array("FIELD" => "SU.EMAIL", "TYPE" => "string"), "PERSONAL_PHOTO" => array("FIELD" => "SU.PERSONAL_PHOTO", "TYPE" => "int"), "EXTERNAL_AUTH_ID" => array("FIELD" => "SU.EXTERNAL_AUTH_ID", "TYPE" => "string"), "USER_ID" => array("FIELD" => "SU.USER_ID", "TYPE" => "int"), "XML_ID" => array("FIELD" => "SU.XML_ID", "TYPE" => "string"), "CAN_DELETE" => array("FIELD" => "SU.CAN_DELETE", "TYPE" => "char"), "PERSONAL_WWW" => array("FIELD" => "SU.PERSONAL_WWW", "TYPE" => "string"));
$arSqls = CGroup::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_socialservices_user SU " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return false;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_socialservices_user SU " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_socialservices_user SU " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . intval($arNavStartParams["nTopCount"]);
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}