Req #67486 [NEW]: inconsistent interface for async

From: Date: Fri, 20 Jun 2014 09:32:40 +0000
Subject: Req #67486 [NEW]: inconsistent interface for async
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186271@lists.php.net to get a copy of this message
From:             robbie86 at gmx dot de
Operating system: Debian 7
PHP version:      5.4.29
Package:          MySQLi related
Bug Type:         Feature/Change Request
Bug description:inconsistent interface for async

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 bug report at https://bugs.php.net/bug.php?id=67486&edit=1
-- 



Thread (4 messages)

« previous php.bugs (#186271) next »