Hi. Your example looks incomplete. What do you do with the records afterwards, which also allows "site" to be removed in a way that you suggest it does not need a code (logic) change?
The general answer is that most interfaces have a way to access the columns by name. I do not know dbi good enough to know how it's done there, but I know I saw it at least once. My personal experience is, that this is needed very seldom, except in very general functions (i.e. in dbi itself :-), because usually, if change/delete a field you have to change the logic, and it's a no-brainer to change the query, too. Btw, "SELECT *" is considered harmful, except if you really write a generic function. Greetings, Benjamin. PS: I use an equivalent of row[i][column++] to avoid having explicit column numbers. Makes it quicker and less error prone to change, if something like "site" if discarded. On Wed 2002-07-10 at 10:49:07 -0700, [EMAIL PROTECTED] wrote: > > Group, > > Given the following code: > > > $sql = qq! select * from table where suffix1 > ''!; > $db_action = $DB->prepare($sql); > $db_action->execute or die "could not do $sql - $DBI::errstr"; > $rows = $db_action->rows; > $rec = $db_action->fetchall_arrayref; > $db_action->finish; > > for ($i=0;$i<$rows;$i++) { > $id = $rec->[$i][0]; > $first_name = $rec->[$i][1]; > $last_name = $rec->[$i][2]; > $identifier = $rec->[$i][3]; > $prefix1 = $rec->[$i][4]; > $suffix1 = $rec->[$i][5]; > $prefix2 = $rec->[$i][6]; > $suffix2 = $rec->[$i][7]; > $site = $rec->[$i][8]; > $location = $rec->[$i][9]; > $phone_loc_id = $rec->[$i][10]; > > I would like to find alternate ways to do this that would take into account > changes to the table. For example let's say that the table changes (for > example lets say that site field in the above example is removed). What I > am interested in, is how are others in the group are handling this type of > thing. I have heard something about tying column names - not sure what this > is. Any and all suggestions will be most appreciated. -- [EMAIL PROTECTED] --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php