|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 18:00:01 2025 UTC |
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; }