note 72095 added to function.mysqli-field-count
| From: | Typer85 at gmail dot com | Date: | Tue, 02 Jan 2007 16:33:56 +0000 |
| Subject: | note 72095 added to function.mysqli-field-count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121193@lists.php.net to get a copy of this message | ||
For those interested and to clarify the Manual Entry.
For query statements that are DESIGNED to return a result set of some sort, this function will
always return the number of fields in the table that was queried.
I said DESIGNED because the return value has no effect on whether or not the actual query matched
any rows or not.
For example, say I have a table that has 2 fields and only 10 rows. I issue the following query:
<?php
// Assume Connection Blah Blah.
mysqli_query( $connObject , "Select * From
table Where Id >
1000");
// Get Number Of Fields.
mysqli_field_count( $connObject );
// Will Return 2 --> The Number of fields in the table!
?>
It is quite clear that the query itself will never return a result set because I asked it to return
rows which have an Id over 1000 and there are only 10 rows.
But because the nature of the query itself is to return a result set, the field count is always
returned no matter what.
In contrast, if the query does anything that does not return a result set by nature, such as an
insert or update, the field count will always be 0.
Hence, you can easily determine the nature of this query dynamically using these return values.
Good Luck,
?>
----
Server IP: 66.163.161.117
Probable Submitter: 84.36.13.52
----
Manual Page -- http://www.php.net/manual/en/function.mysqli-field-count.php
Edit -- https://master.php.net/note/edit/72095
Del: integrated -- https://master.php.net/note/delete/72095/integrated
Del: useless -- https://master.php.net/note/delete/72095/useless
Del: bad code -- https://master.php.net/note/delete/72095/bad+code
Del: spam -- https://master.php.net/note/delete/72095/spam
Del: non-english -- https://master.php.net/note/delete/72095/non-english
Del: in docs -- https://master.php.net/note/delete/72095/in+docs
Del: other reasons-- https://master.php.net/note/delete/72095
Reject -- https://master.php.net/note/reject/72095
Search -- https://master.php.net/manage/user-notes.php