note 83754 added to function.mysql-fetch-field
| From: | david at vitam dot be | Date: | Tue, 10 Jun 2008 12:57:22 +0000 |
| Subject: | note 83754 added to function.mysql-fetch-field | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140305@lists.php.net to get a copy of this message | ||
A little function to help coders to distinct the tablename from a multiselect query where some
fields has the same name in differents tables.
public function sql($sql) {
$T_Return=array();
$result=@mysql_query($sql);
$i=0;
while ($i < mysql_num_fields($result)) {
$fields[]=mysql_fetch_field($result, $i);
$i++;
}
while ($row=mysql_fetch_row($result)) {
$new_row=array();
for($i=0;$i<count($row); $i++) {
$new_row[ $fields[$i]->table][$fields[$i]->name]=$row[$i];
}
$T_Return[]=$new_row;
}
return $T_Return;
}
----
Server IP: 195.207.10.20
Probable Submitter: 84.192.69.106
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-field.php
Edit -- https://master.php.net/note/edit/83754
Del: integrated -- https://master.php.net/note/delete/83754/integrated
Del: useless -- https://master.php.net/note/delete/83754/useless
Del: bad code -- https://master.php.net/note/delete/83754/bad+code
Del: spam -- https://master.php.net/note/delete/83754/spam
Del: non-english -- https://master.php.net/note/delete/83754/non-english
Del: in docs -- https://master.php.net/note/delete/83754/in+docs
Del: other reasons-- https://master.php.net/note/delete/83754
Reject -- https://master.php.net/note/reject/83754
Search -- https://master.php.net/manage/user-notes.php