Author: ahristov
Date: 2007-07-10 18:59:54 +0200 (Tue, 10 Jul 2007)
New Revision: 698
Modified:
trunk/mysqlnd/mysqlnd_ps.c
trunk/php5/ext/mysqli/mysqli_fe.c
trunk/php6/ext/mysqli/mysqli_fe.c
trunk/tests/ext/mysqli/mysqli_stmt_get_result2.phpt
trunk/tests/ext/mysqli/mysqli_stmt_get_result_field_count.phpt
Log:
Fix two mysqli_stmt_get_result() failures.
Fixed method misplaced in the API. What amazes me is that it wasn't found
so long after mysqli is mainstream. There is a property mysqli_result::field_count
but there was also a method, which Ulf by chance hit. The method actually
is linked to mysqli_num_fields() which works on mysqli_conn handles. Thus this
method never worked :( , and there was no mysqli_conn::field_count() method.
Although I am curious whether we need it as we have a property
mysqli_conn::field_count - this is what the sources say.
Modified: trunk/mysqlnd/mysqlnd_ps.c
===================================================================
--- trunk/mysqlnd/mysqlnd_ps.c 2007-07-10 15:43:34 UTC (rev 697)
+++ trunk/mysqlnd/mysqlnd_ps.c 2007-07-10 16:59:54 UTC (rev 698)
@@ -810,6 +810,8 @@
{
if (!stmt->result ||
stmt->state < MYSQLND_STMT_WAITING_USE_OR_STORE) {
+ SET_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
+
return FAIL;
} else if (stmt->state == MYSQLND_STMT_WAITING_USE_OR_STORE) {
/* Execute only once. We have to free the previous contents of user's bound vars */
@@ -914,9 +916,14 @@
SET_EMPTY_ERROR(stmt->error_info);
SET_EMPTY_ERROR(stmt->conn->error_info);
- if (stmt->state < MYSQLND_STMT_PREPARED || !stmt->param_bind) {
+ if (stmt->state < MYSQLND_STMT_PREPARED) {
+ SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
return FAIL;
}
+ if (!stmt->param_bind) {
+ SET_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
+ return FAIL;
+ }
if (param_no >= stmt->param_count) {
SET_STMT_ERROR(stmt, CR_INVALID_PARAMETER_NO, UNKNOWN_SQLSTATE, "Invalid parameter
number");
@@ -1189,7 +1196,7 @@
/* }}} */
-/* {{{ mysqlnd_stmt::param_metadata */
+/* {{{ mysqlnd_stmt::result_metadata */
static MYSQLND_RES *
MYSQLND_METHOD(mysqlnd_stmt, result_metadata)(MYSQLND_STMT * const stmt)
{
Modified: trunk/php5/ext/mysqli/mysqli_fe.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli_fe.c 2007-07-10 15:43:34 UTC (rev 697)
+++ trunk/php5/ext/mysqli/mysqli_fe.c 2007-07-10 16:59:54 UTC (rev 698)
@@ -214,6 +214,7 @@
PHP_FALIAS(master_query,mysqli_master_query,NULL)
PHP_FALIAS(slave_query,mysqli_slave_query,NULL)
#endif
+ PHP_FALIAS(field_count,mysqli_field_count,NULL)
#ifdef HAVE_MYSQLI_GET_CHARSET
PHP_FALIAS(get_charset,mysqli_get_charset,NULL)
#endif
@@ -276,7 +277,6 @@
PHP_FALIAS(fetch_assoc,mysqli_fetch_assoc,NULL)
PHP_FALIAS(fetch_object,mysqli_fetch_object,NULL)
PHP_FALIAS(fetch_row,mysqli_fetch_row,NULL)
- PHP_FALIAS(field_count,mysqli_field_count,NULL)
PHP_FALIAS(field_seek,mysqli_field_seek,NULL)
PHP_FALIAS(free_result,mysqli_free_result,NULL)
{NULL, NULL, NULL}
Modified: trunk/php6/ext/mysqli/mysqli_fe.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli_fe.c 2007-07-10 15:43:34 UTC (rev 697)
+++ trunk/php6/ext/mysqli/mysqli_fe.c 2007-07-10 16:59:54 UTC (rev 698)
@@ -216,6 +216,7 @@
PHP_FALIAS(master_query,mysqli_master_query,NULL)
PHP_FALIAS(slave_query,mysqli_slave_query,NULL)
#endif
+ PHP_FALIAS(field_count,mysqli_field_count,NULL)
#ifdef HAVE_MYSQLI_GET_CHARSET
PHP_FALIAS(get_charset,mysqli_get_charset,NULL)
#endif
@@ -278,7 +279,6 @@
PHP_FALIAS(fetch_assoc,mysqli_fetch_assoc,NULL)
PHP_FALIAS(fetch_object,mysqli_fetch_object,NULL)
PHP_FALIAS(fetch_row,mysqli_fetch_row,NULL)
- PHP_FALIAS(field_count,mysqli_field_count,NULL)
PHP_FALIAS(field_seek,mysqli_field_seek,NULL)
PHP_FALIAS(free_result,mysqli_free_result,NULL)
{NULL, NULL, NULL}
Modified: trunk/tests/ext/mysqli/mysqli_stmt_get_result2.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_stmt_get_result2.phpt 2007-07-10 15:43:34 UTC (rev 697)
+++ trunk/tests/ext/mysqli/mysqli_stmt_get_result2.phpt 2007-07-10 16:59:54 UTC (rev 698)
@@ -163,7 +163,7 @@
string(1) "a"
}
NULL
-[017] [0] Can we have an error message here? It might make sense to bail out already when
binding.
+[017] [2014] Commands out of sync; you can't run this command now
Warning: mysqli_stmt_get_result(): Couldn't fetch mysqli_stmt in %s on line %d
done!
@@ -182,7 +182,7 @@
unicode(1) "a"
}
NULL
-[017] [0] Can we have an error message here?
+[017] [2014] Commands out of sync; you can't run this command now
Warning: mysqli_stmt_get_result(): Couldn't fetch mysqli_stmt in %s on line %d
-done!
\ No newline at end of file
+done!
Modified: trunk/tests/ext/mysqli/mysqli_stmt_get_result_field_count.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_stmt_get_result_field_count.phpt 2007-07-10 15:43:34 UTC
(rev 697)
+++ trunk/tests/ext/mysqli/mysqli_stmt_get_result_field_count.phpt 2007-07-10 16:59:54 UTC
(rev 698)
@@ -30,14 +30,13 @@
}
printf("%s %s\n",
- $res_meta->field_count(),
- $res->field_count());
+ $res_meta->field_count,
+ $res->field_count);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!\n";
-
?>
--EXPECTF--
2 2
-done!
\ No newline at end of file
+done!
| Thread |
|---|
| • PHP mysqlnd svn commit: r698 - in trunk: mysqlnd php5/ext/mysqli php6/ext/mysqli tests/ext/mysqli | ahristov | 10 Jul |