Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5517 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77104 invoked by uid 1010); 18 Nov 2003 09:55:51 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 77079 invoked from network); 18 Nov 2003 09:55:50 -0000 Received: from unknown (HELO ns0.concatel.com) (213.151.99.10) by pb1.pair.com with SMTP; 18 Nov 2003 09:55:50 -0000 Received: (qmail 27275 invoked from network); 18 Nov 2003 09:59:36 -0000 Received: from abazan@filnet.es by cctinet by uid 1001 with qmail-scanner-1.20rc3 (iscan: v3.1/v6.510-1002/684/56446. spamassassin: 2.20. Clear:RC:1:. Processed in 0.304473 secs); 18 Nov 2003 09:59:36 -0000 Received: from unknown (HELO cctpc035) (213.151.99.3) by mx.concatel.com with SMTP; 18 Nov 2003 09:59:36 -0000 Message-ID: <016501c3adba$d94a18a0$3701a8c0@bcn.concatel.com> To: Date: Tue, 18 Nov 2003 11:00:51 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0162_01C3ADC3.3AE54DC0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4927.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 Subject: Sybase "identical field names" feature on sybase_fetch_array() From: abazan@filnet.es ("Alex") ------=_NextPart_000_0162_01C3ADC3.3AE54DC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I've been mailing some lists with this issue without any luck. I = hope this is the right place to post this. I was recently shocked when I discovered the implementation of Sybase = "identical fields". The PHP manual for sybase_fetch_array() reads: Note: When selecting fields with identical names (for instance, in a = join), the associative indices will have a sequential number prepended. = See the example for details. I would like to say that I am against implementing these sort of = repetitive field returns. If a programmer wants multiple (identically = named) fields returned, they can always modify their SQL statement to reflect unique = field names: select t1.id as id1, t2.id as id2 from t1,t2 PHP should NOT be mangling field names returned from the database = driver, it should simply return the name-value of the LAST field of any = given name. However, if this is to be kept in the code, there are a few important = considerations that should be taken into account regarding the = implementation: 1st. Upgading PHP. There are loads of cases where you can find in a = database different tables with some identical field names. I know this = is poor database design, but sometimes you find that you have to work = with a design where this occurs. With this new feature on = sybase_fetch_array() all the code where one just assumed that the = returned value for field X was from the last table selected, MUST BE = RE-WRITTEN. 2nd. IMHO, the implementation of this feature is very poor. When you = have a JOIN over two tables and they have more that one field with the = same name: table A: id date user afield table B: id date user bfield the resulting join will result in id date user id1 date2 user3 afield bfield A single numeric index is incremented for all repetitive fields, making = it impossible to make it dynamic. (if you made a select using different = fields you will get different field names!!!) I suggest correcting this = implementation to return field names as follows: id date user id1 date1 user1 afield bfield One counter for each repeated field instead of one unique counter for = ALL fields. 3rd. Last but not least... This is a feature only implemented in Sybase = library functions, so when creating cross-db applications, it is much more difficult to implement generic code. I would appreciate hearing from the PHP Team about this. Thanks in advance, Alex ---------------------------- Alex Bazan abazan at filnet dot es ------=_NextPart_000_0162_01C3ADC3.3AE54DC0--