本文整理汇总了PHP中Relationship::ManyToOneType方法的典型用法代码示例。如果您正苦于以下问题:PHP Relationship::ManyToOneType方法的具体用法?PHP Relationship::ManyToOneType怎么用?PHP Relationship::ManyToOneType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relationship
的用法示例。
在下文中一共展示了Relationship::ManyToOneType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: CriteriaGroup
/**
* Gets the folders for a user to do certain action.
*
* @param $action Action - that the user intends to do
* @param $user User - the user that tries to get his folders.
* @return Array - vector of folder objects
*/
function &findByPermission($action, $user)
{
$folderQuery = $this->newQueryObject();
$folderClassQuery =& $folderQuery->queryRelationedClass("FolderClass");
$permissionQuery =& $folderClassQuery->queryRelationedClass("Permission");
$actionQuery =& $permissionQuery->queryRelationedClass("Action", Relationship::ManyToOneType());
$roleQuery =& $permissionQuery->queryRelationedClass("Role", Relationship::ManyToOneType());
$roleUserQuery =& $roleQuery->queryRelationedClass("RoleUser");
$criteriaGroup = new CriteriaGroup();
$actionCriteria = new Criteria($actionQuery, "action", $action->getAction());
$criteriaGroup->addCriterion($actionCriteria);
$userCriteria = new Criteria($roleUserQuery, "userID", $user->getId());
$criteriaGroup->addCriterion($userCriteria);
// Set the criterion
$folderQuery->setCriterion($criteriaGroup);
// Execute
return $this->mapAll($folderQuery->execute());
}
示例3: Criteria
/**
* Gets the objects in a given folder
*
* @param $folderId id of a certain folder
* @return List of Object class objects
*/
function &findByFolder($folderId)
{
$objectQuery = $this->newQueryObject();
$objectFolderQuery =& $objectQuery->queryRelationedClass("ObjectFolder");
$folderQuery =& $objectFolderQuery->queryRelationedClass("Folder", Relationship::ManyToOneType());
$criteria =& new Criteria($folderQuery, "ID", $folderId);
$objectQuery->setCriterion($criteria);
$order = new Order($objectFolderQuery, "position", Order::OrderTypeAsc());
$objectQuery->addOrder($order);
return $this->mapAll($objectQuery->execute());
}