note 120045 added to mysqli-result.fetch-fields
| From: | mccharles dot craven at dot dot gov | Date: | Fri, 14 Oct 2016 12:23:50 +0000 |
| Subject: | note 120045 added to mysqli-result.fetch-fields | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206893@lists.php.net to get a copy of this message | ||
Those wanting to map the 'type' field in this function for use in mysqli_stmt_bind_param
or to cannibalize it for their own mapping may find this function useful.
function map_field_type_to_bind_type($field_type)
{
switch ($field_type)
{
case MYSQLI_TYPE_DECIMAL:
case MYSQLI_TYPE_NEWDECIMAL:
case MYSQLI_TYPE_FLOAT:
case MYSQLI_TYPE_DOUBLE:
return 'd';
case MYSQLI_TYPE_BIT:
case MYSQLI_TYPE_TINY:
case MYSQLI_TYPE_SHORT:
case MYSQLI_TYPE_LONG:
case MYSQLI_TYPE_LONGLONG:
case MYSQLI_TYPE_INT24:
case MYSQLI_TYPE_YEAR:
case MYSQLI_TYPE_ENUM:
return 'i';
case MYSQLI_TYPE_TIMESTAMP:
case MYSQLI_TYPE_DATE:
case MYSQLI_TYPE_TIME:
case MYSQLI_TYPE_DATETIME:
case MYSQLI_TYPE_NEWDATE:
case MYSQLI_TYPE_INTERVAL:
case MYSQLI_TYPE_SET:
case MYSQLI_TYPE_VAR_STRING:
case MYSQLI_TYPE_STRING:
case MYSQLI_TYPE_CHAR:
case MYSQLI_TYPE_GEOMETRY:
return 's';
case MYSQLI_TYPE_TINY_BLOB:
case MYSQLI_TYPE_MEDIUM_BLOB:
case MYSQLI_TYPE_LONG_BLOB:
case MYSQLI_TYPE_BLOB:
return 'b';
default:
trigger_error("unknown type: $field_type");
return 's';
}
}
----
Server IP: 72.52.91.14
Probable Submitter: 152.122.1.24
----
Manual Page -- http://php.net/manual/en/mysqli-result.fetch-fields.php
Edit -- https://master.php.net/note/edit/120045
Del: integrated -- https://master.php.net/note/delete/120045/integrated
Del: useless -- https://master.php.net/note/delete/120045/useless
Del: bad code -- https://master.php.net/note/delete/120045/bad+code
Del: spam -- https://master.php.net/note/delete/120045/spam
Del: non-english -- https://master.php.net/note/delete/120045/non-english
Del: in docs -- https://master.php.net/note/delete/120045/in+docs
Del: other reasons-- https://master.php.net/note/delete/120045
Reject -- https://master.php.net/note/reject/120045
Search -- https://master.php.net/manage/user-notes.php