php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
Description:
------------
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?


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 15:01:29 2024 UTC