Skip to content

Commit 00f450a

Browse files
committed
Attempt to fix stmt_attr_set
1 parent a3ee938 commit 00f450a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

ext/mysqli/mysqli_api.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,29 +2243,28 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
22432243
MY_STMT *stmt;
22442244
zval *mysql_stmt;
22452245
zend_long mode_in;
2246+
#if MYSQL_VERSION_ID >= 50107
2247+
my_bool mode_b;
2248+
#endif
22462249
unsigned long mode;
22472250
zend_long attr;
22482251
void *mode_p;
22492252

22502253
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &mysql_stmt, mysqli_stmt_class_entry, &attr, &mode_in) == FAILURE) {
22512254
RETURN_THROWS();
22522255
}
2253-
22542256
MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
22552257

22562258
switch (attr) {
22572259
#if MYSQL_VERSION_ID >= 50107
22582260
case STMT_ATTR_UPDATE_MAX_LENGTH:
2259-
{
2260-
my_bool mode_b;
2261-
if (mode_in != 0 && mode_in != 1) {
2261+
if (mode_in < 0) {
22622262
zend_argument_value_error(ERROR_ARG_POS(3), "must be 0 or 1 for attribute MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH");
22632263
RETURN_THROWS();
22642264
}
22652265
mode_b = (my_bool) mode_in;
22662266
mode_p = &mode_b;
22672267
break;
2268-
}
22692268
#endif
22702269
case STMT_ATTR_CURSOR_TYPE: {
22712270
switch (mode_in) {
@@ -2301,7 +2300,6 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
23012300
RETURN_THROWS();
23022301
}
23032302

2304-
// TODO Can unify this?
23052303
#ifndef MYSQLI_USE_MYSQLND
23062304
if (mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
23072305
#else

ext/mysqli/tests/mysqli_stmt_attr_set.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ require_once("connect.inc");
7171
$stmt->prepare("SELECT label FROM test");
7272
var_dump($stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 1));
7373
$res = $stmt->attr_get(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH);
74-
if ($res !== 1)
75-
printf("[007.1] max_length should be 1, got %s\n", $res);
74+
if ($res !== 1) {
75+
printf("[007.1] max_length should be int 1, got\n");
76+
var_dump($res);
77+
}
7678
$stmt->execute();
7779
$stmt->store_result();
7880
$res = $stmt->result_metadata();

0 commit comments

Comments
 (0)