Re: [PATCH] FreeTDS-Compatible DB_mssql::tableInfo()

From: Date: Tue, 30 Dec 2003 05:01:44 +0000
Subject: Re: [PATCH] FreeTDS-Compatible DB_mssql::tableInfo()
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-24658@lists.php.net to get a copy of this message
You should use the mssql extension with FreeTDS. This is the only way to get full mssql support. Patching the DB::mssql driver to match the sybase function set does not make any sence to me. - Frank > The current DB_mssql::tableInfo() uses mssql_field_name(), > mssql_field_type() and mssql_field_length() to get field information. > These functions don't work when using FreeTDS/Sybase extensions. The > patch below uses mssql_fetch_field() instead, which I believe should > work with both FreeTDS and php_mssql.dll. Note that I haven't tested > that it works on Windows, since I don't have a Windows-based PHP > installation readily available. > > ---cut here--- > Index: mssql.php > =================================================================== > RCS file: /repository/pear/DB/DB/mssql.php,v > retrieving revision 1.19 > diff -u -r1.19 mssql.php > --- mssql.php 5 Dec 2003 22:00:14 -0000 1.19 > +++ mssql.php 29 Dec 2003 22:04:31 -0000 > @@ -493,9 +493,12 @@ > > for ($i=0; $i<$count; $i++) { > $res[$i]['table'] = (is_string($result)) ? $result : > ''; > - $res[$i]['name'] = @mssql_field_name($id, $i); > - $res[$i]['type'] = @mssql_field_type($id, $i); > - $res[$i]['len'] = @mssql_field_length($id, $i); > + > + $fieldInfo=mssql_fetch_field($id,$i); > + $res[$i]['name'] = $fieldInfo['name']; > + $res[$i]['type'] = $fieldInfo['type']; > + $res[$i]['len'] = $fieldInfo['max_length']; > + > // We only support flags for tables > $res[$i]['flags'] = is_string($result) ? > $this->_mssql_field_flags($result, $res[$i]['name']) : ''; > } > @@ -505,10 +508,13 @@ > > for ($i=0; $i<$count; $i++) { > $res[$i]['table'] = (is_string($result)) ? $result : > ''; > - $res[$i]['name'] = @mssql_field_name($id, $i); > - $res[$i]['type'] = @mssql_field_type($id, $i); > - $res[$i]['len'] = @mssql_field_length($id, $i); > - // We only support flags for tables > + > + $fieldInfo=mssql_fetch_field($id,$i); > + $res[$i]['name'] = $fieldInfo['name']; > + $res[$i]['type'] = $fieldInfo['type']; > + $res[$i]['len'] = $fieldInfo['max_length']; > + > + // We only support flags for tables > $res[$i]['flags'] = is_string($result) ? > $this->_mssql_field_flags($result, $res[$i]['name']) : ''; > if ($mode & DB_TABLEINFO_ORDER) { > $res['order'][$res[$i]['name']] = $i; > ---cut here--- > > > -- > Thomas Johnson <thomas@unifiedconsulting.com> > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.pear.dev (#24658) next »