common/services/base/ActiveRecordService.php
public static function generateList( $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable = $modelClass::tableName();

		// Query and Column
		$query	= new Query();
		$column	= $config[ 'column' ] ?? 'id';

		// Conditions, Filters and Sorting
		$conditions	= $config[ 'conditions' ] ?? null;
		$filters	= $config[ 'filters' ] ?? null;
		$order		= $config[ 'order' ] ?? null;

		// Conditions ----------

		$query->select( $column )->from( $modelTable );

		if( isset( $conditions ) ) {

			foreach ( $conditions as $ckey => $condition ) {

				if( is_numeric( $ckey ) ) {

					$query->andWhere( $condition );

					unset( $conditions[ $ckey ] );
				}
			}

			$query->andWhere( $conditions );
		}

		$interfaces = class_implements( static::class );

		if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {

			$statusFilter = $modelClass::STATUS_TERMINATED;

			$query->andWhere( "$modelTable.status<$statusFilter" );
		}

		// Filters -------------

		if( isset( $filters ) ) {

			foreach ( $filters as $filter ) {

				$query	= $query->andFilterWhere( $filter );
			}
		}

		// Sorting -------------

		if( isset( $order ) ) {

			$query->orderBy( $order );
		}

		// Quering -------------

		// Get column
		$query->column();

		// Create command
		$command	= $query->createCommand();

		// Execute the command
		$list		= $command->queryAll();
		$resultList	= [];

		// Result --------------

		foreach ( $list as $item ) {

			$resultList[] = $item[ $column ];
		}

		return $resultList;
	}
public static function generateList( $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable = $modelClass::tableName();

		// Query and Column
		$query	= new Query();
		$column	= $config[ 'column' ] ?? 'id';

		// Conditions, Filters and Sorting
		$conditions	= $config[ 'conditions' ] ?? null;
		$filters	= $config[ 'filters' ] ?? null;
		$order		= $config[ 'order' ] ?? null;

		// Conditions ----------

		$query->select( $column )->from( $modelTable );

		if( isset( $conditions ) ) {

			foreach ( $conditions as $ckey => $condition ) {

				if( is_numeric( $ckey ) ) {

					$query->andWhere( $condition );

					unset( $conditions[ $ckey ] );
				}
			}

			$query->andWhere( $conditions );
		}

		$interfaces = class_implements( static::class );

		if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {

			$statusFilter = $modelClass::STATUS_TERMINATED;

			$query->andWhere( "$modelTable.status<$statusFilter" );
		}

		// Filters -------------

		if( isset( $filters ) ) {

			foreach ( $filters as $filter ) {

				$query	= $query->andFilterWhere( $filter );
			}
		}

		// Sorting -------------

		if( isset( $order ) ) {

			$query->orderBy( $order );
		}

		// Quering -------------

		// Get column
		$query->column();

		// Create command
		$command	= $query->createCommand();

		// Execute the command
		$list		= $command->queryAll();
		$resultList	= [];

		// Result --------------

		foreach ( $list as $item ) {

			$resultList[] = $item[ $column ];
		}

		return $resultList;
	}
public static function generateList ( $ config = [ ] ) { $ modelClass = static :: $ modelClass ; $ modelTable = $ modelClass :: tableName ( ) ; // Query and Column $ query = new Query ( ) ; $ column = $ config [ 'column' ] ?? 'id' ; // Conditions, Filters and Sorting $ conditions = $ config [ 'conditions' ] ?? null ; $ filters = $ config [ 'filters' ] ?? null ; $ order = $ config [ 'order' ] ?? null ; // Conditions ---------- $ query -> select ( $ column ) -> from ( $ modelTable ) ; if ( isset ( $ conditions ) ) { foreach ( $ conditions as $ ckey => $ condition ) { if ( is_numeric ( $ ckey ) ) { $ query -> andWhere ( $ condition ) ; unset ( $ conditions [ $ ckey ] ) ; } } $ query -> andWhere ( $ conditions ) ; } $ interfaces = class_implements ( static :: class ) ; if ( isset ( $ interfaces [ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) { $ statusFilter = $ modelClass :: STATUS_TERMINATED ; $ query -> andWhere ( "$modelTable.status<$statusFilter" ) ; } // Filters ------------- if ( isset ( $ filters ) ) { foreach ( $ filters as $ filter ) { $ query = $ query -> andFilterWhere ( $ filter ) ; } } // Sorting ------------- if ( isset ( $ order ) ) { $ query -> orderBy ( $ order ) ; } // Quering ------------- // Get column $ query -> column ( ) ; // Create command $ command = $ query -> createCommand ( ) ; // Execute the command $ list = $ command -> queryAll ( ) ; $ resultList = [ ] ; // Result -------------- foreach ( $ list as $ item ) { $ resultList [ ] = $ item [ $ column ] ; } return $ resultList ; }
The method generateList returns an array of list for given column
@param array $config
@return array - array of values.
The method generateList returns an array of list for given column