当前位置: 首页>>代码示例>>PHP>>正文


PHP Query::setCriterion方法代码示例

本文整理汇总了PHP中Query::setCriterion方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::setCriterion方法的具体用法?PHP Query::setCriterion怎么用?PHP Query::setCriterion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Query的用法示例。


在下文中一共展示了Query::setCriterion方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Query

 /**
  * Gets RoleUser objects by a roleId
  *
  * @param $roleId role id looked up
  * @return Array - array with RoleUser objects
  */
 function &findByRoleId($roleId)
 {
     $query = new Query("RoleUser");
     $criteria = new Criteria($query, "roleID", $roleId);
     $query->setCriterion($criteria);
     return $this->mapAll($query->execute());
 }
开发者ID:BackupTheBerlios,项目名称:icf-svn,代码行数:13,代码来源:roleUserMapper.php

示例2: Query

 /**
  * Gets the classes whose objects the user can execute certain action
  *
  * @param $action object - The action that the user should be allowed to do
  * @param $user User - The user that holds de permissions
  * @return Array - an array of class objects
  */
 function &findByPermission($action, $user)
 {
     $classQuery = new Query("Class");
     // Navigate relationships
     $folderClassQuery =& $classQuery->queryRelationedClass("FolderClass");
     $permissionQuery =& $folderClassQuery->queryRelationedClass("Permission");
     $actionQuery =& $permissionQuery->queryRelationedClass("Action", Relationship::ManyToOneType());
     $roleQuery =& $permissionQuery->queryRelationedClass("Role", Relationship::ManyToOneType());
     $roleUserQuery =& $roleQuery->queryRelationedClass("RoleUser");
     $userQuery =& $roleUserQuery->queryRelationedClass("User", Relationship::ManyToOneType());
     // Criterias
     $criteriaGroup = new CriteriaGroup();
     $actionCriteria = new Criteria($actionQuery, "action", $action->getAction());
     $userCriteria = new Criteria($userQuery, "ID", $user->getId());
     $criteriaGroup->addCriterion($actionCriteria);
     $criteriaGroup->addCriterion($userCriteria);
     $classQuery->setCriterion($criteriaGroup);
     // sorting
     $order = new Order($classQuery, "title", "ASC");
     $classQuery->addOrder($order);
     // Execute the query
     $recordset =& $classQuery->execute();
     $array = $this->mapAll($recordset);
     return $array;
 }
开发者ID:BackupTheBerlios,项目名称:icf-svn,代码行数:32,代码来源:baseClassMapper.php

示例3: Query

 /**
  * Gets a Role object
  *
  * @param id the Role Id
  * @return the Role object
  */
 function &get($id)
 {
     $query = new Query("Role");
     $criteria = new Criteria($query, "ID", $id);
     $query->setCriterion($criteria);
     return $this->mapOne($query->execute());
 }
开发者ID:BackupTheBerlios,项目名称:icf-svn,代码行数:13,代码来源:roleMapper.php

示例4: findByFolderClassId

 /**
  * Gets a list with permissions for a folderClass object
  * @param $folderClassId FolderClass - the folderClass object
  * @return Array with permission objects
  */
 function findByFolderClassId($folderClassId)
 {
     $query = new Query("Permission");
     $criteria = new Criteria($query, "folderClassID", $folderClassId);
     $query->setCriterion($criteria);
     return $this->mapAll($query->execute());
 }
开发者ID:BackupTheBerlios,项目名称:icf-svn,代码行数:12,代码来源:permissionMapper.php

示例5: findByClassId

 /**
  * Gets a class' attributes
  *
  * @param classId id of a class
  * @return array of class objects
  */
 function findByClassId($classId)
 {
     $query = new Query("ClassAttribute");
     $criteria = new Criteria($query, "classID", $classId);
     $query->setCriterion($criteria);
     $order = new Order($query, "position", Order::OrderTypeAsc());
     $query->addOrder($order);
     return $this->mapAll($query->execute());
 }
开发者ID:BackupTheBerlios,项目名称:icf-svn,代码行数:15,代码来源:classAttributeMapper.php

示例6: findByText

 /**
  * Searches objects by text parameters
  * @param $classId Id of the class
  * @param $text Text to lookup in the objects
  * @param $fullTextSearch if true, the text is searched in all text fields and every coincidence is returned. 
  *				If false, it is only looked up in the title.
  */
 function findByText($classId, $text, $fullTextSearch, $folderId = -1)
 {
     $objectQuery = new Query("Object");
     $criteriaGroup = new CriteriaGroup(CriteriaGroup::getAndSeparator());
     // Lookup by class...
     $criteria = new Criteria($objectQuery, "classID", $classId);
     $criteriaGroup->addCriterion($criteria);
     if ($folderId != -1 && $folderId != null) {
         // Lookup by folder...
         $objectFolderQuery =& $objectQuery->queryRelationedClass("ObjectFolder");
         $folderCriteria = new Criteria($objectFolderQuery, "folderID", $folderId);
         $criteriaGroup->addCriterion($folderCriteria);
     }
     // ... and criterias sent
     if ($fullTextSearch) {
         // by fullTextIndex
         $criteria = new Criteria($objectQuery, "fullTextIndex", $text, Criteria::likeType());
         $criteriaGroup->addCriterion($criteria);
     } else {
         // Issue a query to ObjectAttribute entity
         $objectAttributeQuery =& $objectQuery->queryRelationedClass("ObjectAttribute");
         // Get the class
         $baseClassMapper = new BaseClassMapper();
         $class = $baseClassMapper->get($classId);
         /* @var $class BaseClass */
         // Get the fields that compose the title
         $titleClassAttributesArray = $class->getTitleClassAttributes();
         // We need to query all title fields using the given value with OR (anyone can match)
         $criteriaGroupTitle = new CriteriaGroup(CriteriaGroup::getOrSeparator());
         foreach ($titleClassAttributesArray as $titleClassAttribute) {
             // Must belong to the given class and LIKE the given title
             $criteriaGroupItem = new CriteriaGroup();
             /* @var $titleClassAttribute ClassAttribute */
             $criteriaGroupItem->addCriterion($criteria);
             $criteria = new Criteria($objectAttributeQuery, "classAttributeId", $titleClassAttribute->getId());
             $criteriaGroupItem->addCriterion($criteria);
             $criteria = new Criteria($objectAttributeQuery, "value", $text, Criteria::likeType());
             $criteriaGroupItem->addCriterion($criteria);
             $criteriaGroupTitle->addCriterion($criteriaGroupItem);
         }
         // Set the title criteria
         $criteriaGroup->addCriterion($criteriaGroupTitle);
     }
     $objectQuery->setCriterion($criteriaGroup);
     // Execute the query and map the results
     $objectMapper = new ObjectMapper();
     $rv = $objectMapper->mapAll($objectQuery->execute());
     return $rv;
 }
开发者ID:BackupTheBerlios,项目名称:icf-svn,代码行数:56,代码来源:objectService.php

示例7: Query

echo "Resulting query: " . $query->getQueryString() . "<br/>";
assert("SELECT DISTINCT ##Object.* FROM ##Object LEFT OUTER JOIN ##Class ON ##Object.ID = ##Class.ObjectID WHERE ##Class.className = 'news'" == $query->getQueryString());
echo "Query with CriteriaGroup instead of only one Criteria<br/>";
$query = new Query("object");
$criteriaGroup = new CriteriaGroup(CriteriaGroup::getAndSeparator());
$criteria = new Criteria($query, "hits", "10", Criteria::lessEqualThanType());
$criteriaGroup->addCriterion($criteria);
$criteria = new Criteria($query, "hits", "1", Criteria::moreEqualThanType());
$criteriaGroup->addCriterion($criteria);
$query->setCriterion($criteriaGroup);
echo "Resulting query: " . $query->getQueryString() . "<br/>";
echo "Query with multiples Criteria Groups and an order<br/>";
$query = new Query("object");
$criteriaGroupRoot = new CriteriaGroup(CriteriaGroup::getAndSeparator());
$criteriaGroupOne = new CriteriaGroup(CriteriaGroup::getAndSeparator());
$criteria = new Criteria($query, "created", "2005-04-15", Criteria::lessThanType());
$criteriaGroupOne->addCriterion($criteria);
$criteriaGroupTwo = new CriteriaGroup(CriteriaGroup::getOrSeparator());
$criteria = new Criteria($query, "updatedBy", "1");
$criteriaGroupTwo->addCriterion($criteria);
$criteria = new Criteria($query, "updatedBy", "2");
$criteriaGroupTwo->addCriterion($criteria);
$criteriaGroupRoot->addCriterion($criteriaGroupOne);
$criteriaGroupRoot->addCriterion($criteriaGroupTwo);
$query->setCriterion($criteriaGroupRoot);
$order = new Order($query, "hits", Order::OrderTypeAsc());
$query->addOrder($order);
echo "Resulting query: " . $query->getQueryString() . "<br/>";
$rs = $query->execute();
echo "Executed query: ";
print_r($rs);
开发者ID:BackupTheBerlios,项目名称:icf-svn,代码行数:31,代码来源:queryTest.php


注:本文中的Query::setCriterion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。