1
0
mirror of https://github.com/php/php-src.git synced 2026-03-27 17:52:16 +01:00
This commit is contained in:
Andrey Hristov
2005-04-19 13:42:31 +00:00
parent 28a638fe7b
commit fd13faea13
2 changed files with 53 additions and 8 deletions

View File

@@ -311,6 +311,9 @@ PHP_FUNCTION(mysqli_stmt_bind_result)
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DECIMAL:
#ifdef FIELD_TYPE_NEWDECIMAL
case MYSQL_TYPE_NEWDECIMAL:
#endif
stmt->result.buf[ofs].type = IS_STRING;
stmt->result.buf[ofs].buflen =
(stmt->stmt->fields) ? (stmt->stmt->fields[ofs].length) ? stmt->stmt->fields[ofs].length + 1: 256: 256;
@@ -585,7 +588,7 @@ PHP_FUNCTION(mysqli_stmt_fetch)
zval *mysql_stmt;
unsigned int i;
ulong ret;
long lval;
int lval;
double dval;
my_ulonglong llval;
@@ -611,11 +614,11 @@ PHP_FUNCTION(mysqli_stmt_fetch)
if (!stmt->result.is_null[i]) {
switch (stmt->result.buf[i].type) {
case IS_LONG:
memcpy(&lval, stmt->result.buf[i].val, sizeof(long));
memcpy(&lval, stmt->result.buf[i].val, sizeof(lval));
ZVAL_LONG(stmt->result.vars[i], lval);
break;
case IS_DOUBLE:
memcpy(&dval, stmt->result.buf[i].val, sizeof(double));
memcpy(&dval, stmt->result.buf[i].val, sizeof(dval));
ZVAL_DOUBLE(stmt->result.vars[i], dval);
break;
case IS_STRING:
@@ -749,7 +752,7 @@ PHP_FUNCTION(mysqli_fetch_field_direct)
MYSQL_RES *result;
zval *mysql_result;
MYSQL_FIELD *field;
int offset;
long offset;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_result, mysqli_result_class_entry, &offset) == FAILURE) {
return;
@@ -839,7 +842,7 @@ PHP_FUNCTION(mysqli_field_seek)
{
MYSQL_RES *result;
zval *mysql_result;
unsigned int fieldnr;
unsigned long fieldnr;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_result, mysqli_result_class_entry, &fieldnr) == FAILURE) {
return;
@@ -1029,7 +1032,7 @@ PHP_FUNCTION(mysqli_kill)
{
MY_MYSQL *mysql;
zval *mysql_link;
int processid;
unsigned long processid;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_link, mysqli_link_class_entry, &processid) == FAILURE) {
return;
@@ -1277,7 +1280,7 @@ PHP_FUNCTION(mysqli_real_connect)
MY_MYSQL *mysql;
char *hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL;
unsigned int hostname_len, username_len, passwd_len, dbname_len, socket_len;
unsigned int port=0, flags=0;
unsigned long port=0, flags=0;
zval *mysql_link;
zval *object = getThis();
@@ -1416,7 +1419,8 @@ PHP_FUNCTION(mysqli_stmt_send_long_data)
MY_STMT *stmt;
zval *mysql_stmt;
char *data;
long param_nr, data_len;
long param_nr;
int data_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ols", &mysql_stmt, mysqli_stmt_class_entry, &param_nr, &data, &data_len) == FAILURE) {
@@ -1521,6 +1525,9 @@ PHP_FUNCTION(mysqli_stmt_data_seek)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_stmt, mysqli_stmt_class_entry, &offset) == FAILURE) {
return;
}
if (offset < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be positive");
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");

View File

@@ -0,0 +1,38 @@
--TEST--
Bug #32405
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
include ("connect.inc");
/*** test mysqli_connect 127.0.0.1 ***/
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
/* two fields are needed. the problem does not occur with 1 field only selected. */
$link->query("CREATE TABLE test_users(user_id int(10) unsigned NOT NULL auto_increment, login varchar(50) default '', PRIMARY KEY (user_id))");
$link->query('INSERT INTO test_users VALUES (NULL, "user1"), (NULL, "user2"), (NULL, "user3"), (NULL, "user4")');
if ($stmt = $link->prepare("SELECT SQL_NO_CACHE user_id, login FROM test_users")) {
$stmt->execute();
$stmt->bind_result($col1, $col2);
while ($stmt->fetch()) {
var_dump($col1, $col2);
}
$stmt->close();
}
mysqli_query($link,"DROP TABLE test_users");
mysqli_close($link);
?>
--EXPECT--
int(1)
string(5) "user1"
int(2)
string(5) "user2"
int(3)
string(5) "user3"
int(4)
string(5) "user4"