PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #1410

DB mssql_field_* functions do not work

Details

Submitted2004-05-14 18:18 UTC
Fromjbuchbinder at lawbarn dot com
Assigneddanielc
StatusBogus
PackageDB
PHP Version4.3.4
OSDebian GNU/Linunx
Roadmaps(Not assigned)

Comments

[2004-05-14 18:18 UTC] jbuchbinder at lawbarn dot com

Description:
------------
With the mssql driver, DB dies trying to fetch field names in tableInfo(). My fix (in both places) is to use the mssql_fetch_field() function.

$_f = @mssql_fetch_field($id, $i);
$res[$i]['name'] = $_f->name;
$res[$i]['type'] = $_f->type;
$res[$i]['len'] = $_f->max_length;

Calling $db->tableInfo() using the mssql driver will cause this error if you are using the Sybase interface. It is safer to use mssql_fetch_field.

[2004-05-14 18:51 UTC] jbuchbinder at lawbarn dot com

It doesn't really need a procedural example. The function simply does not work when using the Sybase driver, which I made clear in my initial posting. I also can't give you a tabular example, as it is a simple case of using a function which does not exist in that module. I believe that the only time this happens is when you use php4-sybase to access Microsoft SQL server.

The version of PEAR is also immaterial, as it is a problem in the php4-sybase extension when accessing Microsoft SQL servers. The version I am using is the current Debian testing distribution packaging of php4-pear, which is version 4.3.4-4.

If you still don't believe me that it is immaterial, visit the manual page for that function on php.net (http://www.php.net/manual/en/function.mssql-field-name.php), where the last comment describes the problem in detail.

I quote:
tengel at sonic dot net
07-Oct-2000 07:43

This function isn't supported (PHP 4.0.2) if using
Sybase/FreeTDS to access SQLServer
(linux/solaris/bsd/etc). Instead, use
"mssql_fetch_field()" like so:

$field_name = mssql_fetch_field($query_result, $field_number);
print $field_name->name;

[2004-05-14 19:07 UTC] jbuchbinder at lawbarn dot com

It does not return *anything* if driver 'sybase' is specified. The mssql driver works fine, just not using the function call you used; everything works fine when the mssql driver is patched to use mssql_fetch_field().