src/wcmf/lib/model/mapper/impl/NodeUnifiedRDBMapper.php
protected function addOrderBy(SelectStatement $selectStmt, $orderby, $orderType, $aliasName, $defaultOrder) {
    if ($orderby == null) {
      $orderby = [];
      // use default ordering
      if ($defaultOrder && sizeof($defaultOrder) > 0) {
        foreach ($defaultOrder as $orderDef) {
          $orderby[] = $orderDef['sortFieldName']." ".$orderDef['sortDirection'];
          $orderType = $orderDef['sortType'];
        }
      }
    }
    for ($i=0, $count=sizeof($orderby); $i<$count; $i++) {
      $curOrderBy = $orderby[$i];
      $orderByParts = preg_split('/ /', $curOrderBy);
      $orderAttribute = $orderByParts[0];
      $orderDirection = sizeof($orderByParts) > 1 ? $orderByParts[1] : 'ASC';
      if (strpos($orderAttribute, '.') > 0) {
        // the type is included in the attribute
        $orderAttributeParts = preg_split('/\./', $orderAttribute);
        $orderAttribute = array_pop($orderAttributeParts);
      }
      $mapper = $orderType != null ? self::getMapper($orderType) : $this;
      $orderAttributeDesc = $mapper->getAttribute($orderAttribute);
      if ($orderAttributeDesc instanceof ReferenceDescription) {
      	// add the referenced column without table name
      	$mapper = self::getMapper($orderAttributeDesc->getOtherType());
      	$orderAttributeDesc = $mapper->getAttribute($orderAttributeDesc->getOtherName());
      	$orderColumnName = $orderAttributeDesc->getColumn();
      }
      elseif ($orderAttributeDesc instanceof TransientAttributeDescription) {
      	// skip, because no column exists
      	continue;
      }
      else {
      	// add the column with table name
      	$tableName = $aliasName != null ? $aliasName : $mapper->getRealTableName();
      	$orderColumnName = $tableName.'.'.$orderAttributeDesc->getColumn();
      }
      $selectStmt->order([$orderColumnName.' '.$orderDirection]);
    }
  }
protected function addOrderBy(SelectStatement $selectStmt, $orderby, $orderType, $aliasName, $defaultOrder) {
    if ($orderby == null) {
      $orderby = [];
      // use default ordering
      if ($defaultOrder && sizeof($defaultOrder) > 0) {
        foreach ($defaultOrder as $orderDef) {
          $orderby[] = $orderDef['sortFieldName']." ".$orderDef['sortDirection'];
          $orderType = $orderDef['sortType'];
        }
      }
    }
    for ($i=0, $count=sizeof($orderby); $i<$count; $i++) {
      $curOrderBy = $orderby[$i];
      $orderByParts = preg_split('/ /', $curOrderBy);
      $orderAttribute = $orderByParts[0];
      $orderDirection = sizeof($orderByParts) > 1 ? $orderByParts[1] : 'ASC';
      if (strpos($orderAttribute, '.') > 0) {
        // the type is included in the attribute
        $orderAttributeParts = preg_split('/\./', $orderAttribute);
        $orderAttribute = array_pop($orderAttributeParts);
      }
      $mapper = $orderType != null ? self::getMapper($orderType) : $this;
      $orderAttributeDesc = $mapper->getAttribute($orderAttribute);
      if ($orderAttributeDesc instanceof ReferenceDescription) {
      	// add the referenced column without table name
      	$mapper = self::getMapper($orderAttributeDesc->getOtherType());
      	$orderAttributeDesc = $mapper->getAttribute($orderAttributeDesc->getOtherName());
      	$orderColumnName = $orderAttributeDesc->getColumn();
      }
      elseif ($orderAttributeDesc instanceof TransientAttributeDescription) {
      	// skip, because no column exists
      	continue;
      }
      else {
      	// add the column with table name
      	$tableName = $aliasName != null ? $aliasName : $mapper->getRealTableName();
      	$orderColumnName = $tableName.'.'.$orderAttributeDesc->getColumn();
      }
      $selectStmt->order([$orderColumnName.' '.$orderDirection]);
    }
  }
protected function addOrderBy ( SelectStatement $ selectStmt , $ orderby , $ orderType , $ aliasName , $ defaultOrder ) { if ( $ orderby == null ) { $ orderby = [ ] ; // use default ordering if ( $ defaultOrder && sizeof ( $ defaultOrder ) > 0 ) { foreach ( $ defaultOrder as $ orderDef ) { $ orderby [ ] = $ orderDef [ 'sortFieldName' ] . " " . $ orderDef [ 'sortDirection' ] ; $ orderType = $ orderDef [ 'sortType' ] ; } } } for ( $ i = 0 , $ count = sizeof ( $ orderby ) ; $ i < $ count ; $ i ++ ) { $ curOrderBy = $ orderby [ $ i ] ; $ orderByParts = preg_split ( '/ /' , $ curOrderBy ) ; $ orderAttribute = $ orderByParts [ 0 ] ; $ orderDirection = sizeof ( $ orderByParts ) > 1 ? $ orderByParts [ 1 ] : 'ASC' ; if ( strpos ( $ orderAttribute , '.' ) > 0 ) { // the type is included in the attribute $ orderAttributeParts = preg_split ( '/\./' , $ orderAttribute ) ; $ orderAttribute = array_pop ( $ orderAttributeParts ) ; } $ mapper = $ orderType != null ? self :: getMapper ( $ orderType ) : $ this ; $ orderAttributeDesc = $ mapper -> getAttribute ( $ orderAttribute ) ; if ( $ orderAttributeDesc instanceof ReferenceDescription ) { // add the referenced column without table name $ mapper = self :: getMapper ( $ orderAttributeDesc -> getOtherType ( ) ) ; $ orderAttributeDesc = $ mapper -> getAttribute ( $ orderAttributeDesc -> getOtherName ( ) ) ; $ orderColumnName = $ orderAttributeDesc -> getColumn ( ) ; } elseif ( $ orderAttributeDesc instanceof TransientAttributeDescription ) { // skip, because no column exists continue ; } else { // add the column with table name $ tableName = $ aliasName != null ? $ aliasName : $ mapper -> getRealTableName ( ) ; $ orderColumnName = $ tableName . '.' . $ orderAttributeDesc -> getColumn ( ) ; } $ selectStmt -> order ( [ $ orderColumnName . ' ' . $ orderDirection ] ) ; } }
Add the given order to the select statement
@param $selectStmt The select statement (instance of SelectStatement)
@param $orderby An array holding names of attributes to order by, maybe appended with 'ASC', 'DESC' (maybe null)
@param $orderType The type that define the attributes in orderby (maybe null)
@param $aliasName The table alias name to be used (maybe null)
@param $defaultOrder The default order definition to use, if orderby is null (@see PersistenceMapper::getDefaultOrder())
Add the given order to the select statement