<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.ibase.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.ibase-blob-import.php',
    1 => 'ibase_blob_import',
    2 => 'Create blob, copy file in it, and close it',
  ),
  'up' => 
  array (
    0 => 'ref.ibase.php',
    1 => 'Функції Firebird/InterBase',
  ),
  'prev' => 
  array (
    0 => 'function.ibase-blob-get.php',
    1 => 'ibase_blob_get',
  ),
  'next' => 
  array (
    0 => 'function.ibase-blob-info.php',
    1 => 'ibase_blob_info',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/ibase/functions/ibase-blob-import.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.ibase-blob-import" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ibase_blob_import</h1>
  <p class="verinfo">(PHP 5, PHP 7 &lt; 7.4.0)</p><p class="refpurpose"><span class="refname">ibase_blob_import</span> &mdash; <span class="dc-title">Create blob, copy file in it, and close it</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.ibase-blob-import-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ibase_blob_import</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$link_identifier</code></span>, <span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$file_handle</code></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <div class="methodsynopsis dc-description"><span class="methodname"><strong>ibase_blob_import</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$file_handle</code></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   This function creates a BLOB, reads an entire file into it, closes it and
   returns the assigned BLOB id.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ibase-blob-import-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">link_identifier</code></dt>
     <dd>
      <p class="para">
       An InterBase link identifier. If omitted, the last opened link is
       assumed.
      </p>
     </dd>
    
    
     <dt><code class="parameter">file_handle</code></dt>
     <dd>
      <p class="para">
       The file handle is a handle returned by <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ibase-blob-import-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns the BLOB id on success, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on error.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ibase-blob-import-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>ibase_blob_import()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$dbh </span><span style="color: #007700">= </span><span style="color: #0000BB">ibase_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$host</span><span style="color: #007700">, </span><span style="color: #0000BB">$username</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$filename </span><span style="color: #007700">= </span><span style="color: #DD0000">'/tmp/bar'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$fd </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #DD0000">'r'</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">$fd</span><span style="color: #007700">) {<br /><br />    </span><span style="color: #0000BB">$blob </span><span style="color: #007700">= </span><span style="color: #0000BB">ibase_blob_import</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">, </span><span style="color: #0000BB">$fd</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">);<br /><br />    if (!</span><span style="color: #0000BB">is_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$blob</span><span style="color: #007700">)) {<br />        </span><span style="color: #FF8000">// import failed<br />    </span><span style="color: #007700">} else {<br />        </span><span style="color: #0000BB">$query </span><span style="color: #007700">= </span><span style="color: #DD0000">"INSERT INTO foo (name, data) VALUES ('</span><span style="color: #0000BB">$filename</span><span style="color: #DD0000">', ?)"</span><span style="color: #007700">;<br />        </span><span style="color: #0000BB">$prepared </span><span style="color: #007700">= </span><span style="color: #0000BB">ibase_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">, </span><span style="color: #0000BB">$query</span><span style="color: #007700">);<br />        if (!</span><span style="color: #0000BB">ibase_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$prepared</span><span style="color: #007700">, </span><span style="color: #0000BB">$blob</span><span style="color: #007700">)) {<br />            </span><span style="color: #FF8000">// record insertion failed<br />        </span><span style="color: #007700">}<br />    }<br />} else {<br />    </span><span style="color: #FF8000">// unable to open the data file<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ibase-blob-import-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.ibase-blob-add.php" class="function" rel="rdfs-seeAlso">ibase_blob_add()</a> - Add data into a newly created blob</span></li>
    <li><span class="function"><a href="function.ibase-blob-cancel.php" class="function" rel="rdfs-seeAlso">ibase_blob_cancel()</a> - Cancel creating blob</span></li>
    <li><span class="function"><a href="function.ibase-blob-close.php" class="function" rel="rdfs-seeAlso">ibase_blob_close()</a> - Close blob</span></li>
    <li><span class="function"><a href="function.ibase-blob-create.php" class="function" rel="rdfs-seeAlso">ibase_blob_create()</a> - Create a new blob for adding data</span></li>
   </ul>
  </p>
 </div>


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