No edit summary |
m (refresh SMW properties) |
||
Line 20: | Line 20: | ||
}</nowiki> | }</nowiki> | ||
}} | }} | ||
<noinclude> | <noinclude> | ||
[[Category:Database Functions]]</noinclude> | [[Category:Database Functions]]</noinclude> |
Revision as of 16:41, 11 October 2012
Usage:
$smcFunc['db_num_fields'] (result)
Description: Works exactly like mysql_num_fields. It gets the number of fields in a result.
Parameters:
- result a query resource obtained with db_query.
Return: return exact same results as mysql_num_fields: an integer of false on failure.
Example:
// Get the fields in this row... $field_list = array(); for ($j = 0; $j < $smcFunc['db_num_fields']($result); $j++) { // Try to figure out the type of each field. (NULL, number, or 'string'.) if (!isset($row[$j])) $field_list[] = 'NULL'; elseif (is_numeric($row[$j])) $field_list[] = $row[$j]; else $field_list[] = ''' . $smcFunc['db_escape_string']($row[$j]) . '''; }