Re: Function renaming. First attempt at defining some rules.
| From: | Phil Driscoll | Date: | Wed, 14 Feb 2001 17:11:52 +0000 |
| Subject: | Re: Function renaming. First attempt at defining some rules. | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-2400@lists.php.net to get a copy of this message | ||
>A way to do this is to ask every maintainer of an extention to make a list
>of the extension he supports. That way it would cost much less than 9
>hours for a person. I'd be happy to do this for the mcrypt extension,
>which needs bug fixing anyhow :)
Sounds like a good way of doing it - and if not a maintainer, then at least
the person doing the job needs to have a thorough working knowledge of the
functions. I've just been looking at the function list and have been shocked
at how little of PHP I use.
I've spent the last hour trying to do mysql (just the function names - not
even begun to thing about order of parameters yet). It's hard work - about 2
minutes per function! Here's what I think obeys the rules from my earlier
email (but maybe not!). I may have got the wrong idea as to what some of the
functions I haven't used before do, so there may be big cockups in there.
The main thing I noticed was the horrendous amount of unlearning we need to
do, but we should bear in mind that of all the people who will ever use php,
most of them have never even heard of it yet.
mysql_affected_rows -> mysql_[get]affectedrows
mysql_close -> mysql_close
mysql_connect -> mysql_connect
mysql_create_db -> mysql_create
mysql_data_seek -> mysql_seekdata
mysql_db_query -> mysql_query (note 1)
mysql_drop_db -> mysql_drop
mysql_errno -> mysql_[get]errornumber
mysql_error -> mysql_[get]error[message]
mysql_escape_string -> mysql_escapestring
mysql_fetch_array -> mysql_[get]result (note 2)
mysql_fetch_assoc -> mysql_[get]result (note 2)
mysql_fetch_field -> mysql_[get]field
mysql_fetch_lengths -> mysql_[get]result[field]lengths
mysql_fetch_object -> mysql_[get]result (note 2)
mysql_fetch_row -> mysql_[get]result (note 2)
mysql_field_flags -> mysql_[get]fieldflags
mysql_field_len -> mysql_[get]result[field]length
mysql_field_name -> mysql_[get]result[field]name
mysql_field_seek -> mysql_seekfield
mysql_field_table -> mysql_[get]result[field]table
mysql_field_type -> mysql_[get]result[field]type
mysql_free_result -> mysql_free[result]
mysql_insert_id -> mysql_[get]insertid
mysql_list_dbs -> mysql_getdatabases
mysql_list_fields -> mysql_getfields
mysql_list_tables -> mysql_gettables
mysql_num_fields -> mysql_countresultfields (or maybe
getresultfieldcount)
mysql_num_rows -> mysql_countresultrows (or maybe getresultrowcount)
mysql_pconnect -> mysql_connect (note 3)
mysql_query -> mysql_query
mysql_result -> mysql_[get]resultfield
mysql_select_db -> mysql_select
1. the database name is passed in as an optional extra arg to mysql_query
2. was fetch_array/object - needs optional arg for result type, or
alternatively to be called mysql_getresultarray)
3. pconnect is achieved by passing in a database name as an optional extra
parameter to mysql_connect
Cheers
goes back to hide behind the rock again
--
Phil Driscoll
Dial Solutions
+44 (0)113 294 5112
http://www.dialsolutions.com
http://www.dtonline.org