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


PHP RedBeanModelDataProvider::resolveSortAttributeColumnName方法代码示例

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


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

示例1: getByTask

 /**
  * Given a related model id return a list of check items models.
  * @param integer $taskId
  */
 public static function getByTask($taskId)
 {
     assert('is_int($taskId)');
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('TaskCheckListItem');
     $orderBySortColumnName = RedBeanModelDataProvider::resolveSortAttributeColumnName('TaskCheckListItem', $joinTablesAdapter, 'sortOrder');
     $orderByColumnNameFallback = RedBeanModelDataProvider::resolveSortAttributeColumnName('TaskCheckListItem', $joinTablesAdapter, 'id');
     $where = "task_id = '" . $taskId . "'";
     $orderBy = $orderBySortColumnName . 'asc, ' . $orderByColumnNameFallback . ' desc';
     return self::getSubset($joinTablesAdapter, null, null, $where, $orderBy);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:14,代码来源:TaskCheckListItem.php

示例2: getCommentsByRelatedModelTypeIdAndPageSize

 /**
  * Given a related model type, a related model id, and a page size, return a list of comment models.
  * @param string $type
  * @param integer $relatedId
  * @param integer $pageSize
  */
 public static function getCommentsByRelatedModelTypeIdAndPageSize($type, $relatedId, $pageSize)
 {
     assert('is_string($type)');
     assert('is_int($relatedId)');
     assert('is_int($pageSize) || $pageSize = null');
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Comment');
     $orderByColumnName = RedBeanModelDataProvider::resolveSortAttributeColumnName('Comment', $joinTablesAdapter, 'createdDateTime');
     $where = "relatedmodel_type = '" . strtolower($type) . "' AND relatedmodel_id = '" . $relatedId . "'";
     $orderBy = $orderByColumnName . ' desc';
     return self::getSubset($joinTablesAdapter, null, $pageSize, $where, $orderBy);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:17,代码来源:Comment.php

示例3: testQueryIsProperlyGeneratedForNoteWithRelatedOwnerSearch

 /**
  * This test specifically looks at when searching a note's owner.  Because note extends mashableactivity which
  * does not have a bean, the query is constructed slightly different than if mashableactivity had a bean.
  */
 public function testQueryIsProperlyGeneratedForNoteWithRelatedOwnerSearch()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $_FAKEPOST = array('Note' => array('owner' => array('id' => Yii::app()->user->userModel->id)));
     $metadataAdapter = new SearchDataProviderMetadataAdapter(new Note(false), 1, $_FAKEPOST['Note']);
     $_GET['Note_sort'] = 'description.desc';
     $searchAttributeData = $metadataAdapter->getAdaptedMetadata();
     $quote = DatabaseCompatibilityUtil::getQuote();
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Note');
     $where = RedBeanModelDataProvider::makeWhere('Note', $searchAttributeData, $joinTablesAdapter);
     $orderByColumnName = RedBeanModelDataProvider::resolveSortAttributeColumnName('Note', $joinTablesAdapter, 'description');
     $subsetSql = Note::makeSubsetOrCountSqlQuery('note', $joinTablesAdapter, 1, 5, $where, $orderByColumnName);
     $compareSubsetSql = "select {$quote}note{$quote}.{$quote}id{$quote} id ";
     $compareSubsetSql .= "from ({$quote}note{$quote}, {$quote}activity{$quote}, {$quote}ownedsecurableitem{$quote})";
     $compareSubsetSql .= " where ({$quote}ownedsecurableitem{$quote}.{$quote}owner__user_id{$quote} = " . Yii::app()->user->userModel->id . ")";
     $compareSubsetSql .= " and {$quote}activity{$quote}.{$quote}id{$quote} =";
     $compareSubsetSql .= " {$quote}note{$quote}.{$quote}activity_id{$quote}";
     $compareSubsetSql .= " and {$quote}ownedsecurableitem{$quote}.{$quote}id{$quote} = {$quote}activity{$quote}.{$quote}ownedsecurableitem_id{$quote}";
     $compareSubsetSql .= " order by {$quote}note{$quote}.{$quote}description{$quote} limit 5 offset 1";
     $this->assertEquals($compareSubsetSql, $subsetSql);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:25,代码来源:NoteTest.php

示例4: makeUnionSql

 /**
  * Public for testing purposes only.
  */
 public static function makeUnionSql(array $modelClassNamesAndSearchAttributeData, array $modelClassNamesAndSortAttributes = null, $sortDescending = false, $offset = null, $limit = null)
 {
     assert('$modelClassNamesAndSortAttributes === null ||
                 count($modelClassNamesAndSortAttributes) == count($modelClassNamesAndSearchAttributeData)');
     assert('is_bool($sortDescending)');
     $sqlStatementsToUnion = array();
     foreach ($modelClassNamesAndSearchAttributeData as $identifier => $modelClassNameAndSearchAttributeData) {
         foreach ($modelClassNameAndSearchAttributeData as $modelClassName => $searchAttributeData) {
             $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter($modelClassName);
             $where = ModelDataProviderUtil::makeWhere($modelClassName, $searchAttributeData, $joinTablesAdapter);
             $orderByColumnName = null;
             $tableName = $modelClassName::getTableName($modelClassName);
             if ($modelClassNamesAndSortAttributes !== null) {
                 if (isset($modelClassNamesAndSortAttributes[$modelClassName])) {
                     $orderByColumnName = RedBeanModelDataProvider::resolveSortAttributeColumnName($modelClassName, $joinTablesAdapter, $modelClassNamesAndSortAttributes[$modelClassName]);
                 } else {
                     throw new notSupportedException();
                 }
             }
             $quotedExtraSelectColumnNameAndAliases = array();
             $quotedExtraSelectColumnNameAndAliases["'" . $modelClassName . "'"] = 'modelClassName';
             if ($orderByColumnName != null) {
                 $quotedExtraSelectColumnNameAndAliases[$orderByColumnName] = 'orderByColumn';
             }
             $sqlStatementsToUnion[] = $modelClassName::makeSubsetOrCountSqlQuery($tableName, $joinTablesAdapter, null, null, $where, null, false, $joinTablesAdapter->getSelectDistinct(), $quotedExtraSelectColumnNameAndAliases);
         }
     }
     $orderBy = null;
     if ($modelClassNamesAndSortAttributes !== null) {
         $orderBy = 'orderByColumn';
         if ($sortDescending) {
             $orderBy .= ' desc';
         }
     }
     return self::makeSubsetUnionSqlQuery($sqlStatementsToUnion, $offset, $limit, $orderBy);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:39,代码来源:RedBeanModelsDataProvider.php

示例5: getLastCompletedJobLogByType

 protected static function getLastCompletedJobLogByType($type)
 {
     assert('is_string($type) && $type != ""');
     $searchAttributeData = array();
     $searchAttributeData['clauses'] = array(1 => array('attributeName' => 'type', 'operatorType' => 'equals', 'value' => $type));
     $searchAttributeData['structure'] = '1';
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('JobLog');
     $sort = RedBeanModelDataProvider::resolveSortAttributeColumnName('JobLog', $joinTablesAdapter, 'createdDateTime');
     $where = RedBeanModelDataProvider::makeWhere('JobLog', $searchAttributeData, $joinTablesAdapter);
     $models = JobLog::getSubset($joinTablesAdapter, null, 1, $where, $sort . ' desc');
     if (count($models) > 1) {
         throw new NotSupportedException();
     }
     if (count($models) == 0) {
         return null;
     }
     return $models[0];
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:18,代码来源:JobsToJobsCollectionViewUtil.php

示例6: testResolveSortAttributeColumnName

 /**
  * See ModelDataProviderUtilTest->testResolveSortAttributeColumnName
  */
 public function testResolveSortAttributeColumnName()
 {
     $quote = DatabaseCompatibilityUtil::getQuote();
     //Test a standard non-relation attribute on I
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('I');
     $sort = RedBeanModelDataProvider::resolveSortAttributeColumnName('I', $joinTablesAdapter, 'iMember');
     $this->assertEquals("{$quote}i{$quote}.{$quote}imember{$quote}", $sort);
     $this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount());
     $this->assertEquals(0, $joinTablesAdapter->getLeftTableJoinCount());
     //Test a standard casted up attribute on H from I
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('I');
     $sort = RedBeanModelDataProvider::resolveSortAttributeColumnName('I', $joinTablesAdapter, 'name');
     $this->assertEquals("{$quote}h{$quote}.{$quote}name{$quote}", $sort);
     $this->assertEquals(1, $joinTablesAdapter->getFromTableJoinCount());
     $this->assertEquals(0, $joinTablesAdapter->getLeftTableJoinCount());
     //Test a relation attribute G->g from H
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('H');
     $sort = RedBeanModelDataProvider::resolveSortAttributeColumnName('H', $joinTablesAdapter, 'castUpHasOne');
     $this->assertEquals("{$quote}g{$quote}.{$quote}g{$quote}", $sort);
     $this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount());
     $this->assertEquals(1, $joinTablesAdapter->getLeftTableJoinCount());
     $leftTables = $joinTablesAdapter->getLeftTablesAndAliases();
     $this->assertEquals('g', $leftTables[0]['tableName']);
     //Test a relation attribute G->g where casted up from I
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('I');
     $sort = RedBeanModelDataProvider::resolveSortAttributeColumnName('I', $joinTablesAdapter, 'castUpHasOne');
     $this->assertEquals("{$quote}g{$quote}.{$quote}g{$quote}", $sort);
     $this->assertEquals(1, $joinTablesAdapter->getFromTableJoinCount());
     $this->assertEquals(1, $joinTablesAdapter->getLeftTableJoinCount());
     $fromTables = $joinTablesAdapter->getFromTablesAndAliases();
     $this->assertEquals('h', $fromTables[0]['tableName']);
     $leftTables = $joinTablesAdapter->getLeftTablesAndAliases();
     $this->assertEquals('g', $leftTables[0]['tableName']);
     //Test a customField like TestCustomFieldsModel->industry
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('TestCustomFieldsModel');
     $sort = RedBeanModelDataProvider::resolveSortAttributeColumnName('TestCustomFieldsModel', $joinTablesAdapter, 'industry');
     $this->assertEquals("{$quote}customfield{$quote}.{$quote}value{$quote}", $sort);
     $this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount());
     $this->assertEquals(1, $joinTablesAdapter->getLeftTableJoinCount());
     $leftTables = $joinTablesAdapter->getLeftTablesAndAliases();
     $this->assertEquals('customfield', $leftTables[0]['tableName']);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:45,代码来源:RedBeanModelDataProviderTest.php

示例7: testSortingRelatedOwnerAttribute

 /**
  * @depends testSortingModels
  */
 public function testSortingRelatedOwnerAttribute()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $quote = DatabaseCompatibilityUtil::getQuote();
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Account');
     $orderByColumnName = RedBeanModelDataProvider::resolveSortAttributeColumnName('Account', $joinTablesAdapter, 'owner');
     $this->assertEquals("{$quote}person{$quote}.{$quote}lastname{$quote}", $orderByColumnName);
     $leftTablesAndAliases = $joinTablesAdapter->getLeftTablesAndAliases();
     $this->assertEquals('person', $leftTablesAndAliases[1]['tableName']);
     $this->assertEquals('person', $leftTablesAndAliases[1]['tableAliasName']);
     $this->assertEquals('id', $leftTablesAndAliases[1]['tableJoinIdName']);
     $this->assertEquals('_user', $leftTablesAndAliases[1]['onTableAliasName']);
     $this->assertEquals('person_id', $leftTablesAndAliases[1]['onTableJoinIdName']);
     $subsetSql = Account::makeSubsetOrCountSqlQuery('account', $joinTablesAdapter, 1, 5, null, $orderByColumnName);
     $compareSubsetSql = "select {$quote}account{$quote}.{$quote}id{$quote} id ";
     $compareSubsetSql .= "from ({$quote}account{$quote}, {$quote}ownedsecurableitem{$quote}) ";
     $compareSubsetSql .= "left join {$quote}_user{$quote} on ";
     $compareSubsetSql .= "{$quote}_user{$quote}.{$quote}id{$quote} = {$quote}ownedsecurableitem{$quote}.{$quote}owner__user_id{$quote} ";
     $compareSubsetSql .= "left join {$quote}person{$quote} on ";
     $compareSubsetSql .= "{$quote}person{$quote}.{$quote}id{$quote} = {$quote}_user{$quote}.{$quote}person_id{$quote} ";
     $compareSubsetSql .= " where {$quote}ownedsecurableitem{$quote}.{$quote}id{$quote} = ";
     $compareSubsetSql .= "{$quote}account{$quote}.{$quote}ownedsecurableitem_id{$quote} ";
     $compareSubsetSql .= "order by {$quote}person{$quote}.{$quote}lastname{$quote} limit 5 offset 1";
     $this->assertEquals($compareSubsetSql, $subsetSql);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:28,代码来源:ZurmoModelsDataProviderDocumentationTest.php

示例8: getAllByModuleClassName

 /**
  * @param $moduleClassName
  * @return Array of SavedWorkflow models
  */
 public static function getAllByModuleClassName($moduleClassName)
 {
     assert('is_string($moduleClassName)');
     $searchAttributeData = array();
     $searchAttributeData['clauses'] = array(1 => array('attributeName' => 'moduleClassName', 'operatorType' => 'equals', 'value' => $moduleClassName));
     $searchAttributeData['structure'] = '1';
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('SavedWorkflow');
     $where = RedBeanModelDataProvider::makeWhere('SavedWorkflow', $searchAttributeData, $joinTablesAdapter);
     $orderBy = RedBeanModelDataProvider::resolveSortAttributeColumnName('SavedWorkflow', $joinTablesAdapter, 'order');
     return self::getSubset($joinTablesAdapter, null, null, $where, $orderBy);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:15,代码来源:SavedWorkflow.php


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