本文整理汇总了PHP中Criteria::addInnerJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::addInnerJoin方法的具体用法?PHP Criteria::addInnerJoin怎么用?PHP Criteria::addInnerJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria::addInnerJoin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParents
function getParents($categoryId)
{
$c = new Criteria();
$c->addInnerJoin("categories", "categories.categoryId", "categoryparents.parentId");
$fields = "categoryId, name, urlName, navigationName";
return $this->categoryParent->getParents($categoryId, $c, $fields);
}
示例2: getCategoriesForSelect
function getCategoriesForSelect()
{
$c = new Criteria();
$c->addOrder("parentId");
$c->addInnerJoin("categories", "categories.categoryId", "categoryparents.childId");
$c->add("depth", 1);
return $this->findAll($c, "categoryparents.childId as categoryId, categoryparents.parentId, name, possibleTender", true);
}
示例3: showAction
/**
* Show keywords starting with letter
*/
function showAction($letter)
{
if (!Config::get('keywordsEnabled') || !preg_match("#^[A-Z0-9]\$#", $letter)) {
return $this->return404();
}
//set adPage for display
Display::set("adPage", "letter{$letter}");
$keywordGroups = array();
//retrieve keywors which start with $letter
$keywords = $this->keyword->getKeywordsWithPrefix($letter);
$keywordIds = array();
foreach ($keywords as $keyword) {
$keywordIds[] = $keyword['keywordId'];
}
//Count validated sites which contain keyword
$c = new Criteria();
$c->add("keywordId", $keywordIds, "IN");
$c->addGroup("keywordId");
$c->addInnerJoin("sites", "sites.siteId", "keywordsofsites.siteId");
$c->add("status", "validated");
$sitesCountsForKeyword = $this->keywordsOfSite->getArray($c, "count(*)", "keywordId");
//foreach keyword on this page check have many sites include it and push it to prefix group
foreach ($keywords as $keyword) {
//if some site have this keyword
if (isset($sitesCountsForKeyword[$keyword['keywordId']])) {
$keyword['count'] = $sitesCountsForKeyword[$keyword['keywordId']];
} else {
//if no set counter to default 0
$keyword['count'] = 0;
}
//if group for this prefix doesn't exists so far
if (!isset($keywordGroups[$keyword['prefix']]['keywords'])) {
//create group for this prefix
$keywordGroups[$keyword['prefix']]['keywords'] = array();
}
//add keyword to prefix group
$keywordGroups[$keyword['prefix']]['keywords'][] = $keyword;
}
$this->set("letter", $letter);
$this->set("keywordGroups", $keywordGroups);
}
示例4: getSitesThatOwnAKeyword
function getSitesThatOwnAKeyword($keywordId, $page = false)
{
$c = new Criteria();
$c->add("status", "validated");
$c->addInnerJoin("keywordsofsites", "keywordsofsites.siteId", "sites.siteId");
$c->add("keywordsofsites.keywordId", $keywordId);
$c->addOrder("priority DESC");
$this->addDefaultSortingOrder($c);
if ($page !== false) {
$this->addPageCriteria($c, $page, Config::get("sitesPerPageInKeywords"));
}
return $this->selectWithNewFlag($c);
}
示例5: indexAction
function indexAction()
{
$c = new Criteria();
$c->addInnerJoin("sites", "sites.siteId", "siteproblems.siteId");
$this->set("siteProblems", $this->siteProblem->findAll($c, "siteproblems.*, siteTitle"));
}
示例6: getKeywords
function getKeywords($onlyIds = false)
{
$values = array();
if (!$this->haveKeywords) {
return $values;
}
$c = new Criteria();
$c->add("siteId", $this->siteId);
if ($onlyIds) {
$field = "keywordId";
} else {
$field = "keywords.keywordId, keyword";
$c->addInnerJoin("keywords", "keywords.keywordId", "keywordsofsites.keywordId");
}
foreach (Model::factoryInstance("keywordsOfSite")->findAll($c, $field) as $keyword) {
if ($onlyIds) {
$values[] = $keyword['keywordId'];
} else {
$values[] = $keyword;
}
}
return $values;
}
示例7: saveExtraFieldsValues
function saveExtraFieldsValues($item, $newItem)
{
$fields = $this->getCategoryFieldsWithOptions($item->categoryId);
$itemId = $item->siteId;
$c = new Criteria();
$c->addInnerJoin('extrafields', 'extrafields.fieldId', 'extrafieldvalues.fieldId');
$c->add('type', 'file');
$files = $this->extraFieldValue->getArray($c, 'text', 'extrafields.fieldId');
$c = new Criteria();
$c->add("itemId", $itemId);
$this->extraFieldValue->del($c);
foreach ($fields as $fieldId => $field) {
$extraFieldValue = new ExtraFieldValueRecord();
$extraFieldValue->itemId = $itemId;
$extraFieldValue->fieldId = $fieldId;
if (!isset($newItem->extraField[$fieldId])) {
continue;
}
$newItemExtraFieldData = $newItem->extraField[$fieldId];
try {
switch ($field['type']) {
case "text":
case "textarea":
$extraFieldValue->text = $newItemExtraFieldData;
break;
case "select":
case "radio":
if (!isset($field['options'][$newItemExtraFieldData])) {
continue 2;
}
case "range":
$extraFieldValue->value = $newItemExtraFieldData;
break;
case 'url':
$extraFieldValue->text = serialize($newItemExtraFieldData);
break;
case "checkbox":
$value = 0;
foreach ($newItemExtraFieldData as $checkBoxValue) {
if (!isset($field['options'][$checkBoxValue])) {
continue 3;
}
$value += pow(2, $checkBoxValue - 1);
//minus 1 because we count from 1,2,3,4.. to have 1,2,4,8
}
$extraFieldValue->value = $value;
break;
case 'file':
$file = new UploadedFile('extraField_' . $fieldId . '_file');
if (!empty($files[$fieldId])) {
$data = unserialize($files[$fieldId]);
} else {
$data = array();
}
$data['title'] = $newItemExtraFieldData['title'];
if ($file->wasUploaded()) {
$filesPath = CODE_ROOT_DIR . 'uploads/files/';
$file->setSavePath($filesPath);
$file->save();
$fileSrc = $file->getSavedFileName();
$data['fileSrc'] = $fileSrc;
}
$extraFieldValue->text = serialize($data);
}
$extraFieldValue->save();
} catch (Exception $e) {
}
}
$this->site->updateByPk(array("haveExtraFields" => !empty($newItem->extraField) ? "1" : "0"), $itemId);
}
示例8: keywordAction
/**
* Display sites which have specified keyword
*/
function keywordAction($keywordId, $name, $page)
{
//if this action is disabled
if (!Config::get('keywordsEnabled')) {
return $this->return404();
}
//set adPage for ads
Display::set("adPage", "keyword" . $keywordId);
//get keyword data
$keyword = $this->keyword->findByPk($keywordId);
$this->set("keyword", $keyword);
if (empty($keyword)) {
return $this->return404();
}
if (NameTool::strToAscii($keyword->keyword) != $name) {
$keyword->page = $page;
$this->redirect(AppRouter::getObjectUrl($keyword, "keyword"), 301);
}
//get sites which containt this keyword
$keywordSites = $this->siteList->getSitesThatOwnAKeyword($keywordId, $page);
$this->set("keywordSites", $keywordSites);
//prepare pagination data
$c = new Criteria();
$c->add("status", "validated");
$c->addInnerJoin("keywordsofsites", "keywordsofsites.siteId", "sites.siteId");
$c->add("keywordsofsites.keywordId", $keywordId);
$totalPages = ceil($this->site->getCount($c) / Config::get("sitesPerPageInKeywords"));
$this->set("pageNavigation", array("baseLink" => "/site/keyword/{$keywordId}/{$name}/", "totalPages" => $totalPages, "currentPage" => $page, "title" => $keyword->keyword));
}