src/CrudKit/Data/SQLDataProvider.php
protected function queryColumns ($queryType, $queryValues, $valueType, $keyValue = false, $ignoreNull = false) {
        $target_columns = array();

        if($queryType === "col_list") {
            // The caller has already specified a list of columns
            $target_columns = $queryValues;
        }
        else {
            /**
             * @var  $key
             * @var SQLColumn $col
             */
            foreach($this->columns as $key => $col) {
                if($queryType === "category") {
                    if(in_array($col->category, $queryValues)) {
                        $target_columns []= $key;
                    }
                }
                else if ($queryType === "all") {
                    $target_columns []= $key;
                }
            }
        }

        $results = array();

        foreach($target_columns as $colKey) {
            /**
             * @var $column SQLColumn
             */
            $column = $this->columns[$colKey];
            $resultItem = null;
            switch($valueType) {
                case "id":
                    $resultItem = $colKey;
                    break;
                case "expr":
                    $resultItem = $column->getExpr();
                    break;
                case "exprAs":
                    $resultItem = $column->getExprAs();
                    break;
                case "object":
                    $resultItem = $column;
                    break;
                case "schema":
                    $resultItem = $column->getSchema();
                    break;
                case "summary":
                    $resultItem = $column->getSummaryConfig();
                    break;
                default:
                    //TODO: Throw library-specific exceptions
                    throw new \Exception("Unknown value type $valueType");
            }

            if(is_null($resultItem) && $ignoreNull) {
                continue;
            }

            if($keyValue) {
                $results[$colKey] = $resultItem;
            }
            else {
                $results []= $resultItem;
            }
        }

        return $results;
    }
protected function queryColumns ($queryType, $queryValues, $valueType, $keyValue = false, $ignoreNull = false) {
        $target_columns = array();

        if($queryType === "col_list") {
            // The caller has already specified a list of columns
            $target_columns = $queryValues;
        }
        else {
            /**
             * @var  $key
             * @var SQLColumn $col
             */
            foreach($this->columns as $key => $col) {
                if($queryType === "category") {
                    if(in_array($col->category, $queryValues)) {
                        $target_columns []= $key;
                    }
                }
                else if ($queryType === "all") {
                    $target_columns []= $key;
                }
            }
        }

        $results = array();

        foreach($target_columns as $colKey) {
            /**
             * @var $column SQLColumn
             */
            $column = $this->columns[$colKey];
            $resultItem = null;
            switch($valueType) {
                case "id":
                    $resultItem = $colKey;
                    break;
                case "expr":
                    $resultItem = $column->getExpr();
                    break;
                case "exprAs":
                    $resultItem = $column->getExprAs();
                    break;
                case "object":
                    $resultItem = $column;
                    break;
                case "schema":
                    $resultItem = $column->getSchema();
                    break;
                case "summary":
                    $resultItem = $column->getSummaryConfig();
                    break;
                default:
                    //TODO: Throw library-specific exceptions
                    throw new \Exception("Unknown value type $valueType");
            }

            if(is_null($resultItem) && $ignoreNull) {
                continue;
            }

            if($keyValue) {
                $results[$colKey] = $resultItem;
            }
            else {
                $results []= $resultItem;
            }
        }

        return $results;
    }
protected function queryColumns ( $ queryType , $ queryValues , $ valueType , $ keyValue = false , $ ignoreNull = false ) { $ target_columns = array ( ) ; if ( $ queryType === "col_list" ) { // The caller has already specified a list of columns $ target_columns = $ queryValues ; } else { /**
             * @var  $key
             * @var SQLColumn $col
             */ foreach ( $ this -> columns as $ key => $ col ) { if ( $ queryType === "category" ) { if ( in_array ( $ col -> category , $ queryValues ) ) { $ target_columns [ ] = $ key ; } } else if ( $ queryType === "all" ) { $ target_columns [ ] = $ key ; } } } $ results = array ( ) ; foreach ( $ target_columns as $ colKey ) { /**
             * @var $column SQLColumn
             */ $ column = $ this -> columns [ $ colKey ] ; $ resultItem = null ; switch ( $ valueType ) { case "id" : $ resultItem = $ colKey ; break ; case "expr" : $ resultItem = $ column -> getExpr ( ) ; break ; case "exprAs" : $ resultItem = $ column -> getExprAs ( ) ; break ; case "object" : $ resultItem = $ column ; break ; case "schema" : $ resultItem = $ column -> getSchema ( ) ; break ; case "summary" : $ resultItem = $ column -> getSummaryConfig ( ) ; break ; default : //TODO: Throw library-specific exceptions throw new \ Exception ( "Unknown value type $valueType" ) ; } if ( is_null ( $ resultItem ) && $ ignoreNull ) { continue ; } if ( $ keyValue ) { $ results [ $ colKey ] = $ resultItem ; } else { $ results [ ] = $ resultItem ; } } return $ results ; }
Super cool and useful function to query columns and get a reduced
subset

@param $queryType
@param $queryValues
@param $valueType
@param bool $keyValue
@return array
@throws \Exception
Super cool and useful function to query columns and get a reduced subset