當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Companies::setCondition方法代碼示例

本文整理匯總了PHP中Companies::setCondition方法的典型用法代碼示例。如果您正苦於以下問題:PHP Companies::setCondition方法的具體用法?PHP Companies::setCondition怎麽用?PHP Companies::setCondition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Companies的用法示例。


在下文中一共展示了Companies::setCondition方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: smarty_block_company


//.........這裏部分代碼省略.........
        }
    }
    if (isset($params['areaid'])) {
        if (strpos($params['areaid'], ",")) {
            $conditions['area'] = "c.area_id IN (" . $params['areaid'] . ")";
        } else {
            $area_id = intval($params['areaid']);
            if ($area_id) {
                $conditions['area'] = "c.area_id=" . $area_id;
            }
        }
    }
    if (!empty($_GET['industryid'])) {
        $conditions['industry'] = "c.industry_id=" . intval($_GET['industryid']);
    }
    if (!empty($_GET['areaid'])) {
        $conditions['area'] = "c.area_id=" . intval($_GET['areaid']);
    }
    if (isset($params['groupid'])) {
        $conditions[] = "c.cache_membergroupid=" . $params['groupid'];
    }
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    $orderby = null;
    if (isset($params['orderby'])) {
        if ($params['orderby'] == "rand" || $params['orderby'] == "rand()") {
            $sql = "SELECT max(id) AS max_id,min(id) AS min_id FROM " . $company->table_prefix . "companies";
            $result = $company->GetRow($sql);
            for ($i = 0; $i <= $limit; $i++) {
                $ids[] = mt_rand($result['min_id'], $result['max_id']);
            }
            $conditions[] = "id IN (" . implode(",", $ids) . ")";
        } else {
            $orderby = " ORDER BY " . trim($params['orderby']) . " ";
        }
    } else {
        $orderby = " ORDER BY id DESC ";
    }
    $company->setCondition($conditions);
    $company->setLimitOffset($offset, $limit);
    $mysql_limit = $company->getLimitOffset();
    if (isset($params['limit'])) {
        $mysql_limit = " " . trim($params['limit']);
    }
    $sql = "SELECT c.id as companyid,c.name as companyname,c.name as title,cache_spacename as userid,c.* FROM {$company->table_prefix}companies c " . $company->getCondition() . "{$orderby}" . $mysql_limit . "";
    if (empty($smarty->blockvars[$param_count])) {
        $smarty->blockvars[$param_count] = $company->GetArray($sql);
        if (!$smarty->blockvars[$param_count]) {
            return $repeat = false;
        }
    }
    if (!function_exists("smarty_function_the_url")) {
        require "function.the_url.php";
    }
    if (list($key, $item) = each($smarty->blockvars[$param_count])) {
        $repeat = true;
        $item['rownum'] = $key;
        $item['iteration'] = ++$key;
        if (!empty($item['userid']) && $item['member_id'] > 0) {
            $url = $space_controller->rewrite($item['userid']);
        } else {
            $url = smarty_function_the_url(array("id" => $item['id'], "module" => "company"));
        }
        $item['url'] = $url;
        if (isset($params['titlelen'])) {
            $item['companyname'] = mb_substr($item['name'], 0, $params['titlelen']);
        }
        if (!empty($item['cache_membergroupid'])) {
            $item['avatar'] = $item['groupavatar'] = "images/group/" . $_PB_CACHE['membergroup'][$item['cache_membergroupid']]['avatar'];
        }
        if (!empty($item['picture'])) {
            $item['logo'] = pb_get_attachmenturl($item['picture'], '', 'small');
        }
        $item['areaid'] = $item['area_id'];
        $areas = $company_controller->array_multi2single($_PB_CACHE['area']);
        if (!empty($areas[$item['area_id']])) {
            $item['areaname'] = $areas[$item['area_id']];
        }
        if (!empty($_PB_CACHE['membergroup'][$item['cache_membergroupid']]['name'])) {
            $item['groupname'] = $_PB_CACHE['membergroup'][$item['cache_membergroupid']]['name'];
        }
        $item['link'] = '<a title="' . $item['name'] . '" href="' . $url . '">' . $item['companyname'] . '</a>';
        $item['thumb'] = $item['src'] = $item['logo'];
        $smarty->assign($params['name'], $item);
    } else {
        $repeat = false;
        reset($smarty->blockvars[$param_count]);
    }
    if (!is_null($content)) {
        print $content;
    }
    if (!$repeat) {
        $smarty->blockvars[$param_count] = array();
    }
}
開發者ID:renduples,項目名稱:alibtob,代碼行數:101,代碼來源:block.company.php


注:本文中的Companies::setCondition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。