just a question about behaviour of buffered queries for mysqli driver :
For example in PDO Mysql, something like below will work (if
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY is set to true):
$db = new Zend_Db_Adapter_Pdo_Mysql(array(
'host' => 'localhost',
'username' => 'user',
'password' => 'password',
'dbname' => 'mydb',
'driver_options' => array(
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
)
));
$query = "select * from table1 limit 4";
$query2 = "select * from table2 limit 4";
$stmt = $db->query($query);
$stmt2 = $db->query($query2);
$rs1 = $stmt->fetchAll(); -> 4 first results from table1
$rs2 = $stmt2->fetchAll(); -> 4 first results from table2
Is there a way to have the same behaviour with Zend_Db_Adapter_Mysqli ?
Example :
$db = new Zend_Db_Adapter_Mysqli(array(
'host' => 'localhost',
'username' => 'user',
'password' => 'password',
'dbname' => 'mydb'
));
$query = "select * from table1 limit 4";
$query2 = "select * from table2 limit 4";
$stmt = $db->query($query);
$stmt2 = $db->query($query2);
$rs1 = $stmt->fetchAll(); -> 4 first results from table2
$rs2 = $stmt2->fetchAll(); -> null
Or maybe better to throw an Exception in this case (as PDO does, when
buffered queries is set to false) ? It took me half a day to figure out
where was the error, so hope it will help someone making the migration from
pdo to mysqli more quickly ;)
Generally, working with buffered query seems to not be a good idea if
portability is a concern. It can give some flexibility that cannot be ported
easily. At least an Exception should be thrown in this case. Or maybe I'm
wrong ?
The problem I face is quite complex, I'll try to refactor some parts of the
code if I can't find a solution. But I would like to preserve some features
I found interesting in it. So If you think you have a advice or a solution,
you're welcome :D
Thanks,
Seb
PS:
[+] Tested on ZF 1.6.2->1.7.2 with PHP 5.2.6 on linux
[+] Is that pertinent to fill a bug report for such an issue, concerning the
doc or whatever ?
--
View this message in context: http://www.nabble.com/Buffered-queries-issues---Portability-inconsistency-tp21151504p21151504.html
Sent from the Zend DB mailing list archive at Nabble.com.
没有评论:
发表评论