note 40374 deleted from ref.sybase by nlopess

From: Date: Tue, 02 Mar 2004 15:18:25 +0000
Subject: note 40374 deleted from ref.sybase by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-66105@lists.php.net to get a copy of this message
Note Submitter: amoyer@jetson.com ---- Duplicate field names : Result changed from PHP 4.2.2 to PHP 4.3.4. My problem relates to "duplicate field names" getting a sequence number appended to them. We were in the process of migrating from PHP 4.2.2 to PHP 4.3.4 when I discovered this problem. We coded many, many scripts exploiting the old method where subsequent, duplicated field names would overwrite previous ones. Changing the scripts right now is not an option. An example query is as follows: Select A.*, B.ID From [...] If table A has a field "ID", under the old method, B.ID would overwrite it's value in the records returned in the result set. I've read that this is not compliant with the Sybase documentation, and has been changed as a result; however, I've also read that the updated code addresses this improperly. For my employer's purposes, all we cared about was ensuring that our scripts could work on the new version without losing a week or more in updating old queries, with the chance of missing some -- very risky in an inventory management / shipping / production scenario. In the file "ext/sybase_ct/php_sybase_ct.c", if you search for the function "php_sybase_fetch_hash", you can change the following line from: if (zend_hash_exists(Z_ARRVAL_P(return_value), result->fields[i].name, strlen(result->fields[i].name)+1)) { to: if (0 && zend_hash_exists(Z_ARRVAL_P(return_value), result->fields[i].name, strlen(result->fields[i].name)+1)) { ...to disable the [stupid] sequence number appending code. I would imagine that cross-platform db library developers and other coders in my situation have seen this problem. I haven't found any other material on it on the web. It was this problem that motivated me to get my hands dirty, and I plan on submitting a compilation and/or runtime configuration option that would disable this behavior to make it act just like the mysql_* functions, despite contradicting the Sybase documentation. Maybe this is just me, but I think having 1 counter for all fields is also a very bad idea. You would think that a counter per field would be smarter behavior. Also, this does not consider the following case: Select 'a' As A, 'a' As A1, 'a' As A Albeit a vanilla example, the second instance of "A" would overwrite "A1" blindly. More time should have been spent on this change, and more attention should have been drawn to it. I read a post from "thekid@thekid.de" who made this change originally saying "I see no BC issues AFAIS." Another person posted the same feelings I share. You shouldn't mangle the field names! If I want the field names to be different, I WILL ALIAS THEM MYSELF!!! Investigating, solving, testing, and documenting this problem cost me half a day. Which cost my employer a lot of money. Good thing PHP is free, or he'd really be upset ;-) I could not find any mention of the change in the release notes, though! I think that a switch of some sort, whether compile-time, or runtime, is necessary because how long the "bad" version existed, and the benefits of the "bad" version in terms of similarity to other database libraries. I am disappointed. Anticipate my code contribution. -@

« previous php.notes (#66105) next »