array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'function.ibase-blob-import.php', 1 => 'ibase_blob_import', ), 'up' => array ( 0 => 'ref.ibase.php', 1 => 'Fonctions 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' => 'fr', 'path' => 'reference/ibase/functions/ibase-blob-import.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7 < 7.4.0)
ibase_blob_import — Crée un BLOB iBase, y copie un fichier et le referme
ibase_blob_import() crée un nouveau BLOB
sur la connexion iBase link_identifier
,
y copie le fichier file_handle
en entier, le referme et en
retourne l'identifiant assigné
link_identifier
Un identifiant de connexion à InterBase. S'il est omis, la dernière connexion ouverte sera utilisée.
file_handle
La ressource de fichier, retournée par la fonction fopen().
Retourne l'identifiant du BLOB en cas de succès, ou false
si une erreur survient.
Exemple #1 Exemple avec ibase_blob_import()
<?php
$dbh = ibase_connect($host, $username, $password);
$filename = '/tmp/bar';
$fd = fopen($filename, 'r');
if ($fd) {
$blob = ibase_blob_import($dbh, $fd);
fclose($fd);
if (!is_string($blob)) {
// échec de l'importation
} else {
$query = "INSERT INTO foo (name, data) VALUES ('$filename', ?)";
$prepared = ibase_prepare($dbh, $query);
if (!ibase_execute($prepared, $blob)) {
// échec de l'insertion de l'enregistrement
}
}
} else {
// impossible d'ouvrir le fichier
}
?>