本文整理汇总了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();
}
}