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;
zval *mysql_stmt;
unsigned int i;
ulong ret;
- long lval;
+ int lval;
double dval;
my_ulonglong llval;
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:
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;
{
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;
{
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;
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();
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, ¶m_nr, &data, &data_len) == FAILURE) {
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");
--- /dev/null
+--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"