Req #67486 [Opn->Wfx]: inconsistent interface for async

From: Date: Tue, 10 Jan 2023 15:43:40 +0000
Subject: Req #67486 [Opn->Wfx]: inconsistent interface for async
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243391@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67486&edit=1

 ID:                 67486
 Updated by:         dharman@php.net
 Reported by:        robbie86 at gmx dot de
 Summary:            inconsistent interface for async
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            MySQLi related
 Operating System:   Debian 7
 PHP Version:        5.4.29
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for this suggestion. I like your second option and I think it could be a reasonable
solution. However, I doubt there's a very high demand for this. Inheritance from PHP standard
classes should be avoided. Use composition instead. This would also be a major breaking chance for
the few people that actually use the async API. For this reason, there are no current plans to
change this functionality. 

If you would like to follow up with this request, please start RFC process. IMHO the async API has a
lot more quirks like this that should be ironed out.


Previous Comments:
------------------------------------------------------------------------
[2014-06-20 13:06:58] johannes@php.net

Valid feature request.

------------------------------------------------------------------------
[2014-06-20 09:32:39] robbie86 at gmx dot de

Description:
------------
It's not possible to get the results of an async query in an user-extended mysqli_result.

For synchronous queries you could do:

class DatabaseResult extends mysqli_result {}
$r = mysqli_real_query($link, $query);
$o = new DatabaseResult($link, MYSQLI_STORE_RESULT);

For async the API is limited to mysqli_query() and mysqli_reap_async_query().
mysqli_reap_async_query() not only calls mysqlnd_reap_async_query(), but also
mysql_store_result()/mysql_use_result(). Therefore the mysqli_result constructor is not usable.


Possible solutions:

1) Optional argument to mysqli_reap_async_query() to only call mysqlnd_reap_async_query() but not
mysql_store_result()/mysql_use_result() - not elegant but small fix
2) mysqli_query() should save async case; mysql_store_result() & mysql_use_result() should call
mysqlnd_reap_async_query() automatically; remove mysqli_reap_async_query()


Workaround now (overhead of SELECT 1 query):

$r = $link->multi_query('SELECT 1;'.$query);
$link->use_result()->free();
// do sth. else (async)
$link->next_result();
$o = new DatabaseResult($link, MYSQLI_STORE_RESULT);




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



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


Thread (4 messages)

« previous php.bugs (#243391) next »