[Previous] [Contents] [Next]


Functions to avoid


Several MySQL functions shouldn't be used in practice:

  • The functions of mysql_fetch_field( ) are also available in the non-object-based alternatives mysql_fetch_length( ), mysql_field_flags( ), mysql_field_name( ), mysql_field_len( ), mysql_field_table( ), and mysql_field_type( ); as these functions are almost a complete subset of mysql_fetch_field( ), we don't describe them here.

  • The function mysql_result( ) is a slower alternative to fetching and processing a row with mysql_fetch_row( ) or mysql_fetch_array( ) and shouldn't be used in practice.

  • mysql_fetch_assoc( ) fetches a row of results as an associative array only, providing half the functionality of mysql_fetch_array( ). The other half-fetching into an array accessed by numeric index-is provided by mysql_fetch_row( ). Since mysql_fetch_array( ) provides both sets of functionality-or can provide the same functionality by passing through MYSQL_ASSOC as the second parameter-it should be used instead.

  • mysql_field_seek( ) can seek to a specific field for a subsequent call to mysql_fetch_field( ), but this is redundant because the field number can be supplied directly to mysql_fetch_field( ) as the optional second parameter.

  • mysql_db_query( ) combines the functionality of mysql_select_db( ) and mysql_query( ). This function has been deprecated in recent releases of PHP.


[Previous] [Contents] [Next]