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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.