Mysqli :: $ field_count vs mysqli_result :: $ field_count

I looked in the php manual and found two functions that are very similar to me:

mysqli_result::$field_count or mysqli_num_fields  

      

and

mysqli::$field_count or mysqli_field_count()  

      

Are they diverse?

+3


source to share


2 answers


this can help:

Object oriented style
int mysqli->field_count ;

Procedural style
int mysqli_field_count(mysqli link);

Returns the number of columns for the most recent query on the connection represented by the link parameter. This function can be useful when using the mysqli_store_result function to determine if the query should have produced a non-empty result set or not without knowing the nature of the query.

      

See here for more details: http://dev.mysql.com/doc/apis-php/en/apis-php-mysqli.field-count.html



Object oriented style
int mysqli_result->field_count ;

Procedural style
int mysqli_num_fields(mysqli_result result);
Returns the number of fields from specified result set.

      

See here for more details: http://dev.mysql.com/doc/apis-php/en/apis-php-mysqli-result.field-count.html

you can see in both cases where one receives input and the other does not

+1


source


These two functions take different parameters:

  • mysqli_num_fields()

    takes a variable $con

    - a mysql connection variable - and returns the number of rows for the last query previously generated using that connection.
  • mysqli_field_count()' accepts a

    $ result` variable is the result set of any previous query - and returns the number of rows returned.


You could use mysqli_field_count()

for your last request, but you would never use mysqli_num_fields()

for any request other than the most recent one.

+2


source







All Articles