|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56781 problem binding file parameters
Submitted: 2006-01-18 17:09 UTC Modified: 2006-01-18 23:18 UTC
From: james dot jones at firstinvestors dot com Assigned:
Status: Closed Package: ibm_db2 (PECL)
PHP Version: 5.1.1 OS: Redhat Linux ES 2.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: james dot jones at firstinvestors dot com
New email:
PHP Version: OS:


 [2006-01-18 17:09 UTC] james dot jones at firstinvestors dot com
I am unable to insert a BLOB (stored in a file) into a database. It seems that two methods might work:

1. Bind the name of the file to the BLOB column using DB2_PARAM_FILE.

2. Bind the contents of the file to the BLOB column.

I can't get the first method to work, and the second method seems inefficient. Could one of the developers give me some advice?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-18 23:18 UTC] denials at gmail dot com
Sorry to hear that you're having trouble.

Unit test test_144.phpt distributed with the ibm_db2 extension demonstrates how to bind a BLOB stored in a file into a database using DB2_PARAM_FILE.

The core of the test case is as follows:

$conn = db2_connect($database, $user, $password);

if ($conn) 
    // Drop the test table, in case it exists
    $drop = 'DROP TABLE pictures';
    $result = @db2_exec($conn, $drop);
    // Create the test table
    $create = 'CREATE TABLE pictures (id INTEGER, picture BLOB(500K))';
    $result = db2_exec($conn, $create);
    $stmt = db2_prepare( $conn, "INSERT INTO pictures VALUES (0, ?)" );
    $rc = db2_bind_param( $stmt, 1, "picture", DB2_PARAM_FILE, DB2_BINARY );
    $picture = "./pic1.jpg";

    $rc = db2_execute( $stmt );
    $num = db2_num_rows( $stmt );
    echo $num;
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Oct 20 17:03:35 2021 UTC