FBIRD_BLOB_IMPORT
Purpose
Use the fbird_blob_import function to store a file
in a new blob.
Syntax
<blob_import>
::= fbird_blob_import( [conn_hndl ,] file_hndl
)
Element
|
Type
|
Description
|
conn_hndl
|
resource
|
A valid connection handle
|
file_hndl
|
resource
|
A valid file handle, open for reading
|
<return>
|
mixed
|
String with blob ID upon success, False upon failure
|
Semantics
The fbird_blob_import function creates a blob,
reads an entire file into it, closes it and returns the assigned blob
ID. The file handle is a handle returned by fopen(). The function
returns FALSE on failure.
If a connection handle is not provided, then the
"default" connection will be used. The default connection
is assigned every time you call fbird_connect or fbird_pconnect, so
if you have multiple connections it will be whichever one was
connected last.
Example
The below example checks for the existence of a
file named “autoexec.bat” and inserts its contents into
the table “foo” if the file exists:
$fd = fopen('C:\autoexec.bat', 'r'); if
($fd) { $blob =
ibase_blob_import($fd); fclose($fd); $query
= "INSERT INTO foo (name, data) VALUES ('autoexec.bat',
?)"; ibase_query($query, $blob); } }
See also
fbird_blob_create,
fbird_blob_add
|