note 92996 added to mysqli-result.fetch-field-direct
| From: | gcdreak at example dot com | Date: | Tue, 18 Aug 2009 22:28:16 +0000 |
| Subject: | note 92996 added to mysqli-result.fetch-field-direct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159615@lists.php.net to get a copy of this message | ||
I wrote a simple class to get info about fields.
Try it!
<?php
class MysqlFieldsInfo implements Iterator
{
private $result;
private $position;
private $row;
function __construct($result){
$this->result = $result;
$this->position = 0;
$this->rewind(); // W $results wewnÄtrzny wskaźnik może byÄ przesuniÄty
wiÄc powracamy do poczÄ
tku
}
public function current(){
return $this->row;
}
public function next(){
$this->position++;
$this->row = $this->result->fetch_field();
}
public function valid(){
return (boolean) $this->row;
}
public function key(){
return $this->position;
}
public function rewind(){
$this->position = 0;
$this->result->field_seek(0);
$this->next();
}
// This function show data in table
public function export(){
echo '<table id="db_table_info">';
echo '<tr>
<th>Name</th>
<th>Orgname</th>
<th>Table</th>
<th>Orgtable</th>
<th>Def</th>
<th>Max_length</th>
<th>Length</th>
<th>Charsetnr</th>
<th>Flags</th>
<th>Type</th>
<th>Decimals</th>
</tr>';
while($this->valid()){
echo '<tr>';
printf("\n\t<td>%s</td>\n", $this->current()->name);
printf("\t<td>%s</td>\n", $this->current()->orgname);
printf("\t<td>%s</td>\n", $this->current()->orgtable);
printf("\t<td>%s</td>\n", $this->current()->def);
printf("\t<td>%s</td>\n", $this->current()->max_length);
printf("\t<td>%s</td>\n", $this->current()->length);
printf("\t<td>%s</td>\n", $this->current()->charsetnr);
printf("\t<td>%s</td>\n", $this->current()->flags);
printf("\t<td>%s</td>\n", $this->current()->type);
printf("\t<td>%s</td>\n", $this->current()->decimals);
echo '</tr>';
$this->next();
}
echo '</table>';
}
}
?>
----
Server IP: 82.177.164.100
Probable Submitter: 83.29.11.157
----
Manual Page -- http://www.php.net/manual/en/mysqli-result.fetch-field-direct.php
Edit -- https://master.php.net/note/edit/92996
Del: integrated -- https://master.php.net/note/delete/92996/integrated
Del: useless -- https://master.php.net/note/delete/92996/useless
Del: bad code -- https://master.php.net/note/delete/92996/bad+code
Del: spam -- https://master.php.net/note/delete/92996/spam
Del: non-english -- https://master.php.net/note/delete/92996/non-english
Del: in docs -- https://master.php.net/note/delete/92996/in+docs
Del: other reasons-- https://master.php.net/note/delete/92996
Reject -- https://master.php.net/note/reject/92996
Search -- https://master.php.net/manage/user-notes.php