diff options
Diffstat (limited to 'includes/db/DatabaseMssql.php')
-rw-r--r-- | includes/db/DatabaseMssql.php | 291 |
1 files changed, 185 insertions, 106 deletions
diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index 914ab408..37f5372e 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -28,39 +28,51 @@ * @ingroup Database */ class DatabaseMssql extends DatabaseBase { - var $mInsertId = NULL; - var $mLastResult = NULL; - var $mAffectedRows = NULL; + var $mInsertId = null; + var $mLastResult = null; + var $mAffectedRows = null; var $mPort; function cascadingDeletes() { return true; } + function cleanupTriggers() { return true; } + function strictIPs() { return true; } + function realTimestamps() { return true; } + function implicitGroupby() { return false; } + function implicitOrderby() { return false; } + function functionalIndexes() { return true; } + function unionSupportsOrderAndLimit() { return false; } /** * Usually aborts on failure + * @param string $server + * @param string $user + * @param string $password + * @param string $dbName + * @throws DBConnectionError * @return bool|DatabaseBase|null */ function open( $server, $user, $password, $dbName ) { @@ -84,7 +96,7 @@ class DatabaseMssql extends DatabaseBase { $connectionInfo = array(); - if( $dbName ) { + if ( $dbName ) { $connectionInfo['Database'] = $dbName; } @@ -97,7 +109,7 @@ class DatabaseMssql extends DatabaseBase { $ntAuthPassTest = strtolower( $password ); // Decide which auth scenerio to use - if( $ntAuthPassTest == 'ntauth' && $ntAuthUserTest == 'ntauth' ){ + if ( $ntAuthPassTest == 'ntauth' && $ntAuthUserTest == 'ntauth' ) { // Don't add credentials to $connectionInfo } else { $connectionInfo['UID'] = $user; @@ -139,11 +151,11 @@ class DatabaseMssql extends DatabaseBase { // $this->limitResult(); if ( preg_match( '/\bLIMIT\s*/i', $sql ) ) { // massage LIMIT -> TopN - $sql = $this->LimitToTopN( $sql ) ; + $sql = $this->LimitToTopN( $sql ); } // MSSQL doesn't have EXTRACT(epoch FROM XXX) - if ( preg_match('#\bEXTRACT\s*?\(\s*?EPOCH\s+FROM\b#i', $sql, $matches ) ) { + if ( preg_match( '#\bEXTRACT\s*?\(\s*?EPOCH\s+FROM\b#i', $sql, $matches ) ) { // This is same as UNIX_TIMESTAMP, we need to calc # of seconds from 1970 $sql = str_replace( $matches[0], "DATEDIFF(s,CONVERT(datetime,'1/1/1970'),", $sql ); } @@ -151,7 +163,7 @@ class DatabaseMssql extends DatabaseBase { // perform query $stmt = sqlsrv_query( $this->mConn, $sql ); if ( $stmt == false ) { - $message = "A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See: http://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" . + $message = "A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See: http://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" . "Query: " . htmlentities( $sql ) . "\n" . "Function: " . __METHOD__ . "\n"; // process each error (our driver will give us an array of errors unlike other providers) @@ -197,9 +209,9 @@ class DatabaseMssql extends DatabaseBase { $retErrors = sqlsrv_errors( SQLSRV_ERR_ALL ); if ( $retErrors != null ) { foreach ( $retErrors as $arrError ) { - $strRet .= "SQLState: " . $arrError[ 'SQLSTATE'] . "\n"; - $strRet .= "Error Code: " . $arrError[ 'code'] . "\n"; - $strRet .= "Message: " . $arrError[ 'message'] . "\n"; + $strRet .= "SQLState: " . $arrError['SQLSTATE'] . "\n"; + $strRet .= "Error Code: " . $arrError['code'] . "\n"; + $strRet .= "Message: " . $arrError['message'] . "\n"; } } else { $strRet = "No errors found"; @@ -279,13 +291,13 @@ class DatabaseMssql extends DatabaseBase { * @param $vars Mixed: array or string, field name(s) to be retrieved * @param $conds Mixed: array or string, condition(s) for WHERE * @param $fname String: calling function name (use __METHOD__) for logs/profiling - * @param $options Array: associative array of options (e.g. array('GROUP BY' => 'page_title')), + * @param array $options associative array of options (e.g. array('GROUP BY' => 'page_title')), * see Database::makeSelectOptions code for list of supported stuff * @param $join_conds Array: Associative array of table join conditions (optional) * (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') ) * @return Mixed: database result resource (feed to Database::fetchObject or whatever), or false on failure */ - function select( $table, $vars, $conds = '', $fname = 'DatabaseMssql::select', $options = array(), $join_conds = array() ) + function select( $table, $vars, $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array() ) { $sql = $this->selectSQLText( $table, $vars, $conds, $fname, $options, $join_conds ); if ( isset( $options['EXPLAIN'] ) ) { @@ -304,17 +316,17 @@ class DatabaseMssql extends DatabaseBase { * @param $vars Mixed: Array or string, field name(s) to be retrieved * @param $conds Mixed: Array or string, condition(s) for WHERE * @param $fname String: Calling function name (use __METHOD__) for logs/profiling - * @param $options Array: Associative array of options (e.g. array('GROUP BY' => 'page_title')), + * @param array $options Associative array of options (e.g. array('GROUP BY' => 'page_title')), * see Database::makeSelectOptions code for list of supported stuff * @param $join_conds Array: Associative array of table join conditions (optional) * (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') ) * @return string, the SQL text */ - function selectSQLText( $table, $vars, $conds = '', $fname = 'DatabaseMssql::select', $options = array(), $join_conds = array() ) { + function selectSQLText( $table, $vars, $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array() ) { if ( isset( $options['EXPLAIN'] ) ) { unset( $options['EXPLAIN'] ); } - return parent::selectSQLText( $table, $vars, $conds, $fname, $options, $join_conds ); + return parent::selectSQLText( $table, $vars, $conds, $fname, $options, $join_conds ); } /** @@ -325,14 +337,16 @@ class DatabaseMssql extends DatabaseBase { * Takes same arguments as Database::select() * @return int */ - function estimateRowCount( $table, $vars = '*', $conds = '', $fname = 'DatabaseMssql::estimateRowCount', $options = array() ) { + function estimateRowCount( $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = array() ) { $options['EXPLAIN'] = true;// http://msdn2.microsoft.com/en-us/library/aa259203.aspx $res = $this->select( $table, $vars, $conds, $fname, $options ); $rows = -1; if ( $res ) { $row = $this->fetchRow( $res ); - if ( isset( $row['EstimateRows'] ) ) $rows = $row['EstimateRows']; + if ( isset( $row['EstimateRows'] ) ) { + $rows = $row['EstimateRows']; + } } return $rows; } @@ -342,13 +356,13 @@ class DatabaseMssql extends DatabaseBase { * If errors are explicitly ignored, returns NULL on failure * @return array|bool|null */ - function indexInfo( $table, $index, $fname = 'DatabaseMssql::indexExists' ) { + function indexInfo( $table, $index, $fname = __METHOD__ ) { # This does not return the same info as MYSQL would, but that's OK because MediaWiki never uses the # returned value except to check for the existance of indexes. $sql = "sp_helpindex '" . $table . "'"; $res = $this->query( $sql, $fname ); if ( !$res ) { - return NULL; + return null; } $result = array(); @@ -380,9 +394,14 @@ class DatabaseMssql extends DatabaseBase { * * Usually aborts on failure * If errors are explicitly ignored, returns success + * @param string $table + * @param array $arrToInsert + * @param string $fname + * @param array $options + * @throws DBQueryError * @return bool */ - function insert( $table, $arrToInsert, $fname = 'DatabaseMssql::insert', $options = array() ) { + function insert( $table, $arrToInsert, $fname = __METHOD__, $options = array() ) { # No rows to insert, easy just return now if ( !count( $arrToInsert ) ) { return true; @@ -404,7 +423,7 @@ class DatabaseMssql extends DatabaseBase { $identity = null; $tableRaw = preg_replace( '#\[([^\]]*)\]#', '$1', $table ); // strip matching square brackets from table name $res = $this->doQuery( "SELECT NAME AS idColumn FROM SYS.IDENTITY_COLUMNS WHERE OBJECT_NAME(OBJECT_ID)='{$tableRaw}'" ); - if( $res && $res->numrows() ){ + if ( $res && $res->numrows() ) { // There is an identity for this table. $identity = array_pop( $res->fetch( SQLSRV_FETCH_ASSOC ) ); } @@ -417,13 +436,13 @@ class DatabaseMssql extends DatabaseBase { $identityClause = ''; // if we have an identity column - if( $identity ) { + if ( $identity ) { // iterate through - foreach ($a as $k => $v ) { + foreach ( $a as $k => $v ) { if ( $k == $identity ) { - if( !is_null($v) ){ + if ( !is_null( $v ) ) { // there is a value being passed to us, we need to turn on and off inserted identity - $sqlPre = "SET IDENTITY_INSERT $table ON;" ; + $sqlPre = "SET IDENTITY_INSERT $table ON;"; $sqlPost = ";SET IDENTITY_INSERT $table OFF;"; } else { @@ -474,7 +493,7 @@ class DatabaseMssql extends DatabaseBase { } elseif ( is_array( $value ) || is_object( $value ) ) { if ( is_object( $value ) && strtolower( get_class( $value ) ) == 'blob' ) { $sql .= $this->addQuotes( $value ); - } else { + } else { $sql .= $this->addQuotes( serialize( $value ) ); } } else { @@ -488,10 +507,10 @@ class DatabaseMssql extends DatabaseBase { if ( $ret === false ) { throw new DBQueryError( $this, $this->getErrors(), $this->lastErrno(), $sql, $fname ); - } elseif ( $ret != NULL ) { + } elseif ( $ret != null ) { // remember number of rows affected $this->mAffectedRows = sqlsrv_rows_affected( $ret ); - if ( !is_null($identity) ) { + if ( !is_null( $identity ) ) { // then we want to get the identity column value we were assigned and save it off $row = sqlsrv_fetch_object( $ret ); $this->mInsertId = $row->$identity; @@ -510,20 +529,28 @@ class DatabaseMssql extends DatabaseBase { * Source items may be literals rather than field names, but strings should be quoted with Database::addQuotes() * $conds may be "*" to copy the whole table * srcTable may be an array of tables. - * @return null|\ResultWrapper + * @param string $destTable + * @param array|string $srcTable + * @param array $varMap + * @param array $conds + * @param string $fname + * @param array $insertOptions + * @param array $selectOptions + * @throws DBQueryError + * @return null|ResultWrapper */ - function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'DatabaseMssql::insertSelect', + function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = __METHOD__, $insertOptions = array(), $selectOptions = array() ) { $ret = parent::insertSelect( $destTable, $srcTable, $varMap, $conds, $fname, $insertOptions, $selectOptions ); if ( $ret === false ) { throw new DBQueryError( $this, $this->getErrors(), $this->lastErrno(), /*$sql*/ '', $fname ); - } elseif ( $ret != NULL ) { + } elseif ( $ret != null ) { // remember number of rows affected $this->mAffectedRows = sqlsrv_rows_affected( $ret ); return $ret; } - return NULL; + return null; } /** @@ -590,9 +617,9 @@ class DatabaseMssql extends DatabaseBase { } else { $sql = ' SELECT * FROM ( - SELECT sub2.*, ROW_NUMBER() OVER(ORDER BY sub2.line2) AS line3 FROM ( - SELECT 1 AS line2, sub1.* FROM (' . $sql . ') AS sub1 - ) as sub2 + SELECT sub2.*, ROW_NUMBER() OVER(ORDER BY sub2.line2) AS line3 FROM ( + SELECT 1 AS line2, sub1.* FROM (' . $sql . ') AS sub1 + ) as sub2 ) AS sub3 WHERE line3 BETWEEN ' . ( $offset + 1 ) . ' AND ' . ( $offset + $limit ); return $sql; @@ -627,8 +654,8 @@ class DatabaseMssql extends DatabaseBase { /** * @return string wikitext of a link to the server software's web site */ - public static function getSoftwareLink() { - return "[http://www.microsoft.com/sql/ MS SQL Server]"; + public function getSoftwareLink() { + return "[{{int:version-db-mssql-url}} MS SQL Server]"; } /** @@ -643,11 +670,11 @@ class DatabaseMssql extends DatabaseBase { return $version; } - function tableExists ( $table, $fname = __METHOD__, $schema = false ) { + function tableExists( $table, $fname = __METHOD__, $schema = false ) { $res = sqlsrv_query( $this->mConn, "SELECT * FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_name = '$table'" ); if ( $res === false ) { - print( "Error in tableExists query: " . $this->getErrors() ); + print "Error in tableExists query: " . $this->getErrors(); return false; } if ( sqlsrv_fetch( $res ) ) { @@ -661,12 +688,12 @@ class DatabaseMssql extends DatabaseBase { * Query whether a given column exists in the mediawiki schema * @return bool */ - function fieldExists( $table, $field, $fname = 'DatabaseMssql::fieldExists' ) { + function fieldExists( $table, $field, $fname = __METHOD__ ) { $table = $this->tableName( $table ); $res = sqlsrv_query( $this->mConn, "SELECT DATA_TYPE FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '$table' AND COLUMN_NAME = '$field'" ); if ( $res === false ) { - print( "Error in fieldExists query: " . $this->getErrors() ); + print "Error in fieldExists query: " . $this->getErrors(); return false; } if ( sqlsrv_fetch( $res ) ) { @@ -681,7 +708,7 @@ class DatabaseMssql extends DatabaseBase { $res = sqlsrv_query( $this->mConn, "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '$table' AND COLUMN_NAME = '$field'" ); if ( $res === false ) { - print( "Error in fieldInfo query: " . $this->getErrors() ); + print "Error in fieldInfo query: " . $this->getErrors(); return false; } $meta = $this->fetchRow( $res ); @@ -694,7 +721,7 @@ class DatabaseMssql extends DatabaseBase { /** * Begin a transaction, committing any previously open transaction */ - protected function doBegin( $fname = 'DatabaseMssql::begin' ) { + protected function doBegin( $fname = __METHOD__ ) { sqlsrv_begin_transaction( $this->mConn ); $this->mTrxLevel = 1; } @@ -702,7 +729,7 @@ class DatabaseMssql extends DatabaseBase { /** * End a transaction */ - protected function doCommit( $fname = 'DatabaseMssql::commit' ) { + protected function doCommit( $fname = __METHOD__ ) { sqlsrv_commit( $this->mConn ); $this->mTrxLevel = 0; } @@ -711,7 +738,7 @@ class DatabaseMssql extends DatabaseBase { * Rollback a transaction. * No-op on non-transactional databases. */ - protected function doRollback( $fname = 'DatabaseMssql::rollback' ) { + protected function doRollback( $fname = __METHOD__ ) { sqlsrv_rollback( $this->mConn ); $this->mTrxLevel = 0; } @@ -720,6 +747,8 @@ class DatabaseMssql extends DatabaseBase { * Escapes a identifier for use inm SQL. * Throws an exception if it is invalid. * Reference: http://msdn.microsoft.com/en-us/library/aa224033%28v=SQL.80%29.aspx + * @param $identifier + * @throws MWException * @return string */ private function escapeIdentifier( $identifier ) { @@ -750,17 +779,17 @@ class DatabaseMssql extends DatabaseBase { $newUser = $this->escapeIdentifier( $newUser ); $loginPassword = $this->addQuotes( $loginPassword ); - $this->doQuery("CREATE DATABASE $dbName;"); - $this->doQuery("USE $dbName;"); - $this->doQuery("CREATE SCHEMA $dbName;"); - $this->doQuery(" + $this->doQuery( "CREATE DATABASE $dbName;" ); + $this->doQuery( "USE $dbName;" ); + $this->doQuery( "CREATE SCHEMA $dbName;" ); + $this->doQuery( " CREATE LOGIN $newUser WITH PASSWORD=$loginPassword ; - "); - $this->doQuery(" + " ); + $this->doQuery( " CREATE USER $newUser FOR @@ -768,8 +797,8 @@ class DatabaseMssql extends DatabaseBase { WITH DEFAULT_SCHEMA=$dbName ; - "); - $this->doQuery(" + " ); + $this->doQuery( " GRANT BACKUP DATABASE, BACKUP LOG, @@ -784,17 +813,15 @@ class DatabaseMssql extends DatabaseBase { DATABASE::$dbName TO $newUser ; - "); - $this->doQuery(" + " ); + $this->doQuery( " GRANT CONTROL ON SCHEMA::$dbName TO $newUser ; - "); - - + " ); } function encodeBlob( $b ) { @@ -873,7 +900,7 @@ class DatabaseMssql extends DatabaseBase { /** * @private * - * @param $options Array: an associative array of options to be turned into + * @param array $options an associative array of options to be turned into * an SQL query, valid keys are listed in the function. * @return Array */ @@ -888,29 +915,23 @@ class DatabaseMssql extends DatabaseBase { } } - if ( isset( $options['GROUP BY'] ) ) { - $tailOpts .= " GROUP BY {$options['GROUP BY']}"; - } - if ( isset( $options['HAVING'] ) ) { - $tailOpts .= " HAVING {$options['GROUP BY']}"; - } - if ( isset( $options['ORDER BY'] ) ) { - $tailOpts .= " ORDER BY {$options['ORDER BY']}"; - } + $tailOpts .= $this->makeGroupByWithHaving( $options ); + + $tailOpts .= $this->makeOrderBy( $options ); if ( isset( $noKeyOptions['DISTINCT'] ) && isset( $noKeyOptions['DISTINCTROW'] ) ) { $startOpts .= 'DISTINCT'; } // we want this to be compatible with the output of parent::makeSelectOptions() - return array( $startOpts, '' , $tailOpts, '' ); + return array( $startOpts, '', $tailOpts, '' ); } /** * Get the type of the DBMS, as it appears in $wgDBtype. * @return string */ - function getType(){ + function getType() { return 'mssql'; } @@ -940,7 +961,7 @@ class DatabaseMssql extends DatabaseBase { */ class MssqlField implements Field { private $name, $tablename, $default, $max_length, $nullable, $type; - function __construct ( $info ) { + function __construct( $info ) { $this->name = $info['COLUMN_NAME']; $this->tablename = $info['TABLE_NAME']; $this->default = $info['COLUMN_DEFAULT']; @@ -990,7 +1011,7 @@ class MssqlResult { $rows = sqlsrv_fetch_array( $queryresult, SQLSRV_FETCH_ASSOC ); - foreach( $rows as $row ) { + foreach ( $rows as $row ) { if ( $row !== null ) { foreach ( $row as $k => $v ) { if ( is_object( $v ) && method_exists( $v, 'format' ) ) {// DateTime Object @@ -1028,7 +1049,7 @@ class MssqlResult { $arrNum[] = $value; } } - switch( $mode ) { + switch ( $mode ) { case SQLSRV_FETCH_ASSOC: $ret = $this->mRows[$this->mCursor]; break; @@ -1081,43 +1102,101 @@ class MssqlResult { $i++; } // http://msdn.microsoft.com/en-us/library/cc296183.aspx contains type table - switch( $intType ) { - case SQLSRV_SQLTYPE_BIGINT: $strType = 'bigint'; break; - case SQLSRV_SQLTYPE_BINARY: $strType = 'binary'; break; - case SQLSRV_SQLTYPE_BIT: $strType = 'bit'; break; - case SQLSRV_SQLTYPE_CHAR: $strType = 'char'; break; - case SQLSRV_SQLTYPE_DATETIME: $strType = 'datetime'; break; - case SQLSRV_SQLTYPE_DECIMAL/*($precision, $scale)*/: $strType = 'decimal'; break; - case SQLSRV_SQLTYPE_FLOAT: $strType = 'float'; break; - case SQLSRV_SQLTYPE_IMAGE: $strType = 'image'; break; - case SQLSRV_SQLTYPE_INT: $strType = 'int'; break; - case SQLSRV_SQLTYPE_MONEY: $strType = 'money'; break; - case SQLSRV_SQLTYPE_NCHAR/*($charCount)*/: $strType = 'nchar'; break; - case SQLSRV_SQLTYPE_NUMERIC/*($precision, $scale)*/: $strType = 'numeric'; break; - case SQLSRV_SQLTYPE_NVARCHAR/*($charCount)*/: $strType = 'nvarchar'; break; - // case SQLSRV_SQLTYPE_NVARCHAR('max'): $strType = 'nvarchar(MAX)'; break; - case SQLSRV_SQLTYPE_NTEXT: $strType = 'ntext'; break; - case SQLSRV_SQLTYPE_REAL: $strType = 'real'; break; - case SQLSRV_SQLTYPE_SMALLDATETIME: $strType = 'smalldatetime'; break; - case SQLSRV_SQLTYPE_SMALLINT: $strType = 'smallint'; break; - case SQLSRV_SQLTYPE_SMALLMONEY: $strType = 'smallmoney'; break; - case SQLSRV_SQLTYPE_TEXT: $strType = 'text'; break; - case SQLSRV_SQLTYPE_TIMESTAMP: $strType = 'timestamp'; break; - case SQLSRV_SQLTYPE_TINYINT: $strType = 'tinyint'; break; - case SQLSRV_SQLTYPE_UNIQUEIDENTIFIER: $strType = 'uniqueidentifier'; break; - case SQLSRV_SQLTYPE_UDT: $strType = 'UDT'; break; - case SQLSRV_SQLTYPE_VARBINARY/*($byteCount)*/: $strType = 'varbinary'; break; - // case SQLSRV_SQLTYPE_VARBINARY('max'): $strType = 'varbinary(MAX)'; break; - case SQLSRV_SQLTYPE_VARCHAR/*($charCount)*/: $strType = 'varchar'; break; - // case SQLSRV_SQLTYPE_VARCHAR('max'): $strType = 'varchar(MAX)'; break; - case SQLSRV_SQLTYPE_XML: $strType = 'xml'; break; - default: $strType = $intType; + switch ( $intType ) { + case SQLSRV_SQLTYPE_BIGINT: + $strType = 'bigint'; + break; + case SQLSRV_SQLTYPE_BINARY: + $strType = 'binary'; + break; + case SQLSRV_SQLTYPE_BIT: + $strType = 'bit'; + break; + case SQLSRV_SQLTYPE_CHAR: + $strType = 'char'; + break; + case SQLSRV_SQLTYPE_DATETIME: + $strType = 'datetime'; + break; + case SQLSRV_SQLTYPE_DECIMAL: // ($precision, $scale) + $strType = 'decimal'; + break; + case SQLSRV_SQLTYPE_FLOAT: + $strType = 'float'; + break; + case SQLSRV_SQLTYPE_IMAGE: + $strType = 'image'; + break; + case SQLSRV_SQLTYPE_INT: + $strType = 'int'; + break; + case SQLSRV_SQLTYPE_MONEY: + $strType = 'money'; + break; + case SQLSRV_SQLTYPE_NCHAR: // ($charCount): + $strType = 'nchar'; + break; + case SQLSRV_SQLTYPE_NUMERIC: // ($precision, $scale): + $strType = 'numeric'; + break; + case SQLSRV_SQLTYPE_NVARCHAR: // ($charCount) + $strType = 'nvarchar'; + break; + // case SQLSRV_SQLTYPE_NVARCHAR('max'): + // $strType = 'nvarchar(MAX)'; + // break; + case SQLSRV_SQLTYPE_NTEXT: + $strType = 'ntext'; + break; + case SQLSRV_SQLTYPE_REAL: + $strType = 'real'; + break; + case SQLSRV_SQLTYPE_SMALLDATETIME: + $strType = 'smalldatetime'; + break; + case SQLSRV_SQLTYPE_SMALLINT: + $strType = 'smallint'; + break; + case SQLSRV_SQLTYPE_SMALLMONEY: + $strType = 'smallmoney'; + break; + case SQLSRV_SQLTYPE_TEXT: + $strType = 'text'; + break; + case SQLSRV_SQLTYPE_TIMESTAMP: + $strType = 'timestamp'; + break; + case SQLSRV_SQLTYPE_TINYINT: + $strType = 'tinyint'; + break; + case SQLSRV_SQLTYPE_UNIQUEIDENTIFIER: + $strType = 'uniqueidentifier'; + break; + case SQLSRV_SQLTYPE_UDT: + $strType = 'UDT'; + break; + case SQLSRV_SQLTYPE_VARBINARY: // ($byteCount) + $strType = 'varbinary'; + break; + // case SQLSRV_SQLTYPE_VARBINARY('max'): + // $strType = 'varbinary(MAX)'; + // break; + case SQLSRV_SQLTYPE_VARCHAR: // ($charCount) + $strType = 'varchar'; + break; + // case SQLSRV_SQLTYPE_VARCHAR('max'): + // $strType = 'varchar(MAX)'; + // break; + case SQLSRV_SQLTYPE_XML: + $strType = 'xml'; + break; + default: + $strType = $intType; } return $strType; } public function free() { unset( $this->mRows ); - return; } } |