irm-1.6-b3/MDB/querysim.php
/**
     * Convert QuerySim text into an array
     *
     * @param string Text of simulated query
     *
     * @access private
     *
     * @return multi-dimensional array containing the column names and data
     *                                 from the QuerySim
     */
Convert QuerySim text into an array
@param string Text of simulated query

@access private

@return multi-dimensional array containing the column names and data
from the QuerySim
Convert QuerySim text into an array @param string Text of simulated query @access private @return multi - dimensional array containing the column names and data from the QuerySim
function _buildResult($query)
    {
        $eolDelim    = $this->options['eolDelim'];
        $columnDelim = $this->options['columnDelim'];
        $dataDelim   = $this->options['dataDelim'];
        $columnNames = array();
        $data        = array();
        if ($columnDelim == $eolDelim) {
            return $this->raiseError(MDB_ERROR_INVALID, null, null,
                'columnDelim and eolDelim must be different');
        } elseif ($dataDelim == $eolDelim){
            return $this->raiseError(MDB_ERROR_INVALID, null, null,
                'dataDelim and eolDelim must be different');
        }
        $query = trim($query);
        $query = str_replace('\\\\', '[$double-slash$]', $query);
        if (!strlen($query)) {
            return $this->raiseError(MDB_ERROR_SYNTAX, null, null,
                'empty querysim text');
        }
        $lineData = $this->_parseOnDelim($query, $eolDelim);
        if (!strlen(trim($lineData[count($lineData) - 1]))) {
            unset($lineData[count($lineData) - 1]);
        }
        $thisLine = each($lineData);
        $columnNames = $this->_parseOnDelim($thisLine[1], $columnDelim);
        if ((in_array('', $columnNames)) || (in_array('null', $columnNames))) {
            return $this->raiseError(MDB_ERROR_SYNTAX, null, null,
                'all column names must be defined');
        }
        $columnNames = str_replace('[$double-slash$]', '\\', $columnNames);
        $columnCount = count($columnNames);
        $rowNum = 0;
        if (count($lineData) > 1) {
            while ($thisLine = each($lineData)) {
                $thisData = $this->_parseOnDelim($thisLine[1], $dataDelim);
                $thisDataCount = count($thisData);
                if ($thisDataCount != $columnCount) {
                    $fileLineNo = $rowNum + 2;
                    return $this->raiseError(MDB_ERROR_SYNTAX, null, null,
                        "number of data elements ($thisDataCount) in line $fileLineNo not equal to number of defined columns ($columnCount)");
                }
                foreach ($thisData as $thisElement) {
                    if (strtolower($thisElement) == 'null'){
                        $thisElement = '';
                    }
                    $data[$rowNum][] = str_replace('[$double-slash$]', '\\', $thisElement);
                }
                ++$rowNum;
            }
        }
        return array($columnNames, $data);
    }
function _buildResult ( $ query ) { $ eolDelim = $ this -> options [ 'eolDelim' ] ; $ columnDelim = $ this -> options [ 'columnDelim' ] ; $ dataDelim = $ this -> options [ 'dataDelim' ] ; $ columnNames = array ( ) ; $ data = array ( ) ; if ( $ columnDelim == $ eolDelim ) { return $ this -> raiseError ( MDB_ERROR_INVALID , null , null , 'columnDelim and eolDelim must be different' ) ; } elseif ( $ dataDelim == $ eolDelim ) { return $ this -> raiseError ( MDB_ERROR_INVALID , null , null , 'dataDelim and eolDelim must be different' ) ; } $ query = trim ( $ query ) ; $ query = str_replace ( '\\\\' , '[$double-slash$]' , $ query ) ; if ( ! strlen ( $ query ) ) { return $ this -> raiseError ( MDB_ERROR_SYNTAX , null , null , 'empty querysim text' ) ; } $ lineData = $ this -> _parseOnDelim ( $ query , $ eolDelim ) ; if ( ! strlen ( trim ( $ lineData [ count ( $ lineData ) - 1 ] ) ) ) { unset ( $ lineData [ count ( $ lineData ) - 1 ] ) ; } $ thisLine = each ( $ lineData ) ; $ columnNames = $ this -> _parseOnDelim ( $ thisLine [ 1 ] , $ columnDelim ) ; if ( ( in_array ( '' , $ columnNames ) ) || ( in_array ( 'null' , $ columnNames ) ) ) { return $ this -> raiseError ( MDB_ERROR_SYNTAX , null , null , 'all column names must be defined' ) ; } $ columnNames = str_replace ( '[$double-slash$]' , '\\' , $ columnNames ) ; $ columnCount = count ( $ columnNames ) ; $ rowNum = 0 ; if ( count ( $ lineData ) > 1 ) { while ( $ thisLine = each ( $ lineData ) ) { $ thisData = $ this -> _parseOnDelim ( $ thisLine [ 1 ] , $ dataDelim ) ; $ thisDataCount = count ( $ thisData ) ; if ( $ thisDataCount != $ columnCount ) { $ fileLineNo = $ rowNum + 2 ; return $ this -> raiseError ( MDB_ERROR_SYNTAX , null , null , " number of data elements ( $ thisDataCount ) in line  $ fileLineNo  not equal to number of defined columns ( $ columnCount ) " ) ; } foreach ( $ thisData as $ thisElement ) { if ( strtolower ( $ thisElement ) == 'null' ) { $ thisElement = '' ; } $ data [ $ rowNum ] [ ] = str_replace ( '[$double-slash$]' , '\\' , $ thisElement ) ; } ++ $ rowNum ; } } return array ( $ columnNames , $ data ) ; }
Convert QuerySim text into an array
 @param string Text of simulated query
Convert QuerySim text into an array @param string Text of simulated query
//tokenize escaped slashes //kill the empty last row created by final eol char if it exists //populate columnNames array //replace double-slash tokens with single-slash //loop through data lines //loop through data elements in data line //replace double-slash tokens with single-slash //end foreach //end while //end if