<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.uodbc.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.odbc-binmode.php',
    1 => 'odbc_binmode',
    2 => 'Handling of binary column data',
  ),
  'up' => 
  array (
    0 => 'ref.uodbc.php',
    1 => 'ODBC 函数',
  ),
  'prev' => 
  array (
    0 => 'function.odbc-autocommit.php',
    1 => 'odbc_autocommit',
  ),
  'next' => 
  array (
    0 => 'function.odbc-close.php',
    1 => 'odbc_close',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/uodbc/functions/odbc-binmode.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.odbc-binmode" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">odbc_binmode</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">odbc_binmode</span> &mdash; <span class="dc-title">Handling of binary column data</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.odbc-binmode-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>odbc_binmode</strong></span>(<span class="methodparam"><span class="type">Odbc\Result</span> <code class="parameter">$statement</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code></span>): <span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></div>

  <p class="para rdfs-comment">
   Controls handling of binary column data. ODBC SQL types affected are
   <code class="literal">BINARY</code>, <code class="literal">VARBINARY</code>, and
   <code class="literal">LONGVARBINARY</code>.
   The default mode can be set using the
   <a href="odbc.configuration.php#ini.uodbc.defaultbinmode" class="link">uodbc.defaultbinmode</a> <var class="filename">php.ini</var> directive.
  </p>
  <p class="para">
   When binary SQL data is converted to character C data (<strong><code><a href="uodbc.constants.php#constant.odbc-binmode-convert">ODBC_BINMODE_CONVERT</a></code></strong>), each byte
   (8 bits) of source data is represented as two ASCII characters.
   These characters are the ASCII character representation of the
   number in its hexadecimal form. For example, a binary
   <code class="literal">00000001</code> is converted to
   <code class="literal">&quot;01&quot;</code> and a binary <code class="literal">11111111</code>
   is converted to <code class="literal">&quot;FF&quot;</code>.
  </p>
  <p class="para">
   While the handling of <code class="literal">BINARY</code> and <code class="literal">VARBINARY</code>
   columns only depend on the binmode, the handling of <code class="literal">LONGVARBINARY</code>
   columns also depends on the longreadlen as well:
   <table class="doctable table">
    <caption><strong>LONGVARBINARY handling</strong></caption>
    
     <thead>
      <tr>
       <th>binmode</th>
       <th>longreadlen</th>
       <th>result</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td><strong><code><a href="uodbc.constants.php#constant.odbc-binmode-passthru">ODBC_BINMODE_PASSTHRU</a></code></strong></td>
       <td>0</td>
       <td>passthru</td>
      </tr>

      <tr>
       <td><strong><code><a href="uodbc.constants.php#constant.odbc-binmode-return">ODBC_BINMODE_RETURN</a></code></strong></td>
       <td>0</td>
       <td>passthru</td>
      </tr>

      <tr>
       <td><strong><code><a href="uodbc.constants.php#constant.odbc-binmode-convert">ODBC_BINMODE_CONVERT</a></code></strong></td>
       <td>0</td>
       <td>passthru</td>
      </tr>

      <tr>
       <td><strong><code><a href="uodbc.constants.php#constant.odbc-binmode-passthru">ODBC_BINMODE_PASSTHRU</a></code></strong></td>
       <td>&gt;0</td>
       <td>passthru</td>
      </tr>

      <tr>
       <td><strong><code><a href="uodbc.constants.php#constant.odbc-binmode-return">ODBC_BINMODE_RETURN</a></code></strong></td>
       <td>&gt;0</td>
       <td>return as is</td>
      </tr>

      <tr>
       <td><strong><code><a href="uodbc.constants.php#constant.odbc-binmode-convert">ODBC_BINMODE_CONVERT</a></code></strong></td>
       <td>&gt;0</td>
       <td>return as char</td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="para">
   If <span class="function"><a href="function.odbc-fetch-into.php" class="function">odbc_fetch_into()</a></span> is used, passthru means that an
   empty string is returned for these columns.
   If <span class="function"><a href="function.odbc-result.php" class="function">odbc_result()</a></span> is used, passthru means that the data are
   sent directly to the client (i.e. printed).
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.odbc-binmode-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">statement</code></dt>
     <dd>
      <p class="para">
       ODBC 结果对象.
      </p>
     </dd>
    
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       Possible values for <code class="parameter">mode</code> are:
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="uodbc.constants.php#constant.odbc-binmode-passthru">ODBC_BINMODE_PASSTHRU</a></code></strong>: Passthru BINARY data
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="uodbc.constants.php#constant.odbc-binmode-return">ODBC_BINMODE_RETURN</a></code></strong>: Return as is
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code><a href="uodbc.constants.php#constant.odbc-binmode-convert">ODBC_BINMODE_CONVERT</a></code></strong>: Convert to char and return
         </span>
        </li>
       </ul>
       <blockquote class="note"><p><strong class="note">注意</strong>: 
        <span class="simpara">
         Handling of binary long
         columns is also affected by <span class="function"><a href="function.odbc-longreadlen.php" class="function">odbc_longreadlen()</a></span>.
        </span>
       </p></blockquote>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.odbc-binmode-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   总是返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.odbc-binmode-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.4.0</td>
 <td>
  <code class="parameter">statement</code> 现在需要 <span class="classname"><strong class="classname">Odbc\Result</strong></span>
  实例；之前需要 <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>。
 </td>
</tr>

    </tbody>
   
  </table>

 </div>

</div><?php manual_footer($setup); ?>