ID:               35155
 User updated by:  f dot engelhardt at 21torr dot com
 Reported By:      f dot engelhardt at 21torr dot com
 Status:           Open
 Bug Type:         MySQLi related
 Operating System: Linux 2.6
 PHP Version:      5CVS-2005-11-09 (snap)
 Assigned To:      georg
 New Comment:

Hello,

i have a hint for you: The size inserted into the database is exactly
the size, that strlen() returns, BUT: strlen stops on  the first \0 and
in a real binary file, this sign can be everywhere, not just at the end.
In your case, i 
found this:

php-5.0.5/ext/mysqli/mysqli_api.c:161

case 's': /* string */
bind[ofs].buffer_type = MYSQL_TYPE_VAR_STRING;
bind[ofs].buffer = NULL;
bind[ofs].buffer_length = 0;
bind[ofs].is_null = &stmt->param.is_null[ofs];

I tried this, and i found out, that it works with
MYSQL_TYPE_VAR_STRING, but you have to specify the length. If i insert
the right lengt, everything works as expected.

So you just have to define the length for the data that is in the bound
variable.

Kind regards

Florian Engelhardt


Previous Comments:
------------------------------------------------------------------------

[2005-11-11 09:55:55] f dot engelhardt at 21torr dot com

Well, i allready tried this:

<?php

mysqli_connect(..);
mysqli_select_db(..);

$s =
file_get_contents('/usr/portage/distfiles/vim-runtime-20050601.tar.bz2');

$one = 1;
$two = 2;

$q = 'INSERT INTO dbfs_data_chunk VALUES (?,?,?)';
$stmt = mysqli_stmt_init($GLOBALS['CONN']);
mysqli_stmt_prepare($stmt,$q);
mysqli_stmt_bind_param($stmt,'iis',$one,$two,$s);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);

exit;

?>

Exaclty the same problem.

Fix it.

Kind Regards

Florian Engelhardt

------------------------------------------------------------------------

[2005-11-11 08:51:46] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

from http://www.php.net/mysql_stmt_bind_param

Character Description
b         corresponding variable is a blob and will be send in
packages

For sending a blob in packages, you have to use
mysql_stmt_send_long_data. If you don't want to do this (e.g. your data
doesn't need escaping and is < max_allowed_package) use type "s"
(=string).

------------------------------------------------------------------------

[2005-11-09 16:07:10] f dot engelhardt at 21torr dot com

This Problem is very annoying, becouse i am using innodb tables with
foreign key constraints, and if i use mysqli_stmt_send_long_data() for
any of the fields, all the other arent NULL anymore. So my constraint
fails!

Example:
<?php

$GLOBALS['CONN'] = mysqli_connect(...);

mysqli_select_db(..);

$s =
file_get_contents('/usr/portage/distfiles/vim-runtime-20050601.tar.bz2')
;

$one = NULL;
$two = NULL;

$q = 'INSERT INTO dbfs_data_chunk VALUES (?,?,?)';
$stmt = mysqli_stmt_init($GLOBALS['CONN']);
mysqli_stmt_prepare($stmt,$q);
mysqli_stmt_bind_param($stmt,'iib',$one,$two,$s);
//mysqli_stmt_send_long_data($stmt,2,$s);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);

exit;

?>

without mysqli_stmt_send_long_data() i have the problem as described,
and with mysqli_stmt_send_long_data() on the blob field, mysql tells
me, that the constraint gets violated!
This can only happen, if the variables $one and $two are not  NULL.

------------------------------------------------------------------------

[2005-11-08 23:28:54] [EMAIL PROTECTED]

Assigned to the maintainer.

------------------------------------------------------------------------

[2005-11-08 23:26:59] f dot engelhardt at 21torr dot com

it doesn´t work, but the behavior changed a little:
Every insert without mysqli_stmt_send_long_data()
inserts 0 Bytes into the blob field, with this function
it works as in the other version (5.0.5)

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/35155

-- 
Edit this bug report at http://bugs.php.net/?id=35155&edit=1

Reply via email to