|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28314 sybase-ct's MSSQL_ASSOC not defined
Submitted: 2004-05-07 16:11 UTC Modified: 2004-05-08 16:20 UTC
From: adamh at densi dot com Assigned:
Status: Not a bug Package: Sybase-ct (ctlib) related
PHP Version: 4.3.4 OS: Linux
Private report: No CVE-ID: None
 [2004-05-07 16:11 UTC] adamh at densi dot com
From PEAR's DB.php:

$ar = @mssql_fetch_array($result, MSSQL_ASSOC);

According to the documentation, this should work. On Windows, it does. However, when using the Sybase CT library (for example, apt-get install php4-sybase on Debian), this line will fail because MSSQL_ASSOC isn't defined.

Reproduce code:

print MSSQL_ASSOC . "\n";


Expected result:

Actual result:
PHP Notice:  Use of undefined constant MSSQL_ASSOC - assumed 'MSSQL_ASSOC' in /home/adam/t.php on line 3

Notice: Use of undefined constant MSSQL_ASSOC - assumed 'MSSQL_ASSOC' in /home/adam/t.php on line 3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-07 17:47 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Sounds like you don't actually load the sybase extensions. 
Make sure that php -m shows "mssql". 
 [2004-05-07 17:57 UTC] adamh at densi dot com
I respectfully disagree. Sybase_ct gives access to the mssql_fetch_array() function and yet the function does *not* follow the documentation. This is obviously a bug in sybase_ct!

php -m does not show mssql; however, it does show sybase_ct. And mssql_fetch_array() is defined and works... but not the way it is supposed to.
 [2004-05-07 18:02 UTC]
The MSSQL_ASSOC constant is ONLY defined by the mssql 
extension. The sybase extension does not define this 
constant because sybase_fetch_array() (on which 
mssql_fetch_array()) is based on in sybase* extension does 
not support this feature. You should instead be using the 
sybase_fetch_assoc() function. 
 [2004-05-07 18:16 UTC] adamh at densi dot com
I'm delving into the source, so please correct me if I err:

Inside the source, sybase_fetch_array() and sybase_fetch_assoc() both call php_sybase_fetch_hash(), in exactly the same manner as php_mssql_fetch_hash().

In other words, mssql_fetch_assoc($r) (the "real" one) is equivalent to mssql_fetch_array($r, MSSQL_ASSOC) internally, since both functions call php_mssql_fetch_hash() with different arguments. I see a direct parallel to Sybase_ct's php_sybase_fetch_hash(), with two differences:

1. php_sybase_fetch_hash() doesn't parse for the possible second argument.
2. MSSQL_ASSOC is not defined.

However, both of these issues are trivial to resolve, aren't they? It seems to me that sybase_ct should conform to mssql on commonly used, well-documented functions.
 [2004-05-07 23:46 UTC]
If you want to use the mssql_* functions you can use the --with-mssql option. This requires FreeTDS.
 [2004-05-08 14:40 UTC] adamh at densi dot com
Yes, obviously I can use mssql_* functions using FreeTDS. But I can *also* use them with --with-sybase-ct. When I use them with SybaseCT, they do not behave as documented.

To me, the FreeTDS argument sounds like, "If you've found a bug in strlen() with uClibc, you can use glibc instead." And yes, I can, but that doesn't mean uClibc doesn't have a bug.

This seems so clear-cut to me I know I must be missing something. Why is this not a bug?
 [2004-05-08 14:50 UTC]
Because you need to have the mssql extension loaded to use its constants.
 [2004-05-08 16:20 UTC]
When you compile with Sybase-ct you will nt get the mssql functions, but the sybase functions and a set of aliases. If you look at the documentation you will see that the mssql extension includes a larger number of functions than the sybase extensions. The mssql aliases provided by the sybase extension was implemented before the 'native' mssql extension was available on *nix.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri May 24 15:01:26 2019 UTC