Jump to content

mysqli_fetch_fields ?


venturemc

Recommended Posts

Having trouble extracting the values form the mysqli_fetch_fields command.

 

......
             $fldinfo = $result->fetch_fields();

foreach ($fldinfo as $fld){

	$rd[$ctr]['index'] = $ctr;
	$rd[$ctr]['fldname'] = $fld->name;   	
	$rd[$ctr]['fldtype'] = $fld->type;	
	$rd[$ctr]['flag'] = $fld->flags;	
	$rd[$ctr]['length'] = $fld->length;
	$rd[$ctr]['inval'] = '';
	$rd[$ctr]['outval'] = '';	
	$ctr++;			

    }
.........

 

I get this on my browser:

Unknown element type
Unknown element type
Unknown element type
Unknown element type

 

I'm assuming that at least part of the issue is because I need to translate the actual data in the fetch_field array, but can't seem to find how to do that.

 

I'm not versed in using classes etc, so i'm still doing things procederally for now. Does that matter in this case?

 

I also tried this syntax, which failed miserably

          foreach ($fldinfo as $fld =>$f){

	$rd[$ctr]['index'] = $ctr;
	$rd[$ctr]['fldname'] = $f['name'];
........   	

 

Any suggestions, clues?

 

What a frustrating language this is....

Link to comment
https://forums.phpfreaks.com/topic/173052-mysqli_fetch_fields/
Share on other sites

OK, this is what I got, which is what I'm expecting...

 

Array ( [0] => stdClass Object ( 
[name] => tx_name 
[orgname] => name 
[table] => tbl_form_temp 
[orgtable] => tbl_form_temp 
[def] => 
[max_length] => 3 
[length] => 50 
[charsetnr] => 8 
[flags] => 4225 
[type] => 253 
[decimals] => 0 ) 

 

there was more (4 fields total as expected), but don't think it's necessary.

 

Link to comment
https://forums.phpfreaks.com/topic/173052-mysqli_fetch_fields/#findComment-912139
Share on other sites

OK, not sure how else to put it.....

1. I'm using the mysqli_fetch_fields function to extract information about a table.

2. The information I want is getting into the $fldinfo array that calls the function (see my second post which results from print_r($fld).

3. I want to  store these values in another array ($rd) for future processing

4. All I get in array "$rd" after my loop is "unknown element type"

 

How do I reach the dat that's in $fld_info? The only example I've seen of the use of this function is a print statement, which doesn't help me here.

Link to comment
https://forums.phpfreaks.com/topic/173052-mysqli_fetch_fields/#findComment-912471
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.