Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[ZF2-281] Cannot Count rows in a MySQLi Result Set #1080

Closed
wants to merge 5 commits into from

2 participants

@erasertwo

In case a mysqli_stmt class is the resource for the result, no mysqli_stmt::store_result() was called. This will prevent some functions (count, rewind, etc.) to work correctly. Furthermore the result is not transferred from the prepared statement (performance loss) and multiple loop over the result set is also not possible.

This commit should fix the above bug.

erasertwo added some commits
@erasertwo erasertwo Fixed Mysqli/Result (count not working, result not retrievable)
In case a mysqli_stmt class is the resource for the result, no mysqli_stmt::store_result() was called. This will prevent some functions (count, rewind, etc.) to work correctly. Furthermore the result is not transferred from the prepared statement (performance loss) and multiple loop over the result set is also not possible.

This commit should fix the above bug.
0c3e10b
@erasertwo erasertwo Merge remote-tracking branch 'upstream/master' 639c8d2
@erasertwo erasertwo Merge remote-tracking branch 'remotes/upstream/master' 9a2c840
@erasertwo erasertwo Merge remote-tracking branch 'remotes/upstream/master' af4f811
@erasertwo erasertwo Merge remote-tracking branch 'remotes/upstream/master'
Conflicts:
	library/Zend/Db/Adapter/Driver/Mysqli/Result.php
64d407c
@erasertwo

Request #1201 fixes this problem. Closed.

@erasertwo erasertwo closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 22, 2012
  1. @erasertwo

    Fixed Mysqli/Result (count not working, result not retrievable)

    erasertwo authored
    In case a mysqli_stmt class is the resource for the result, no mysqli_stmt::store_result() was called. This will prevent some functions (count, rewind, etc.) to work correctly. Furthermore the result is not transferred from the prepared statement (performance loss) and multiple loop over the result set is also not possible.
    
    This commit should fix the above bug.
Commits on Apr 25, 2012
  1. @erasertwo
Commits on Apr 27, 2012
  1. @erasertwo
Commits on May 3, 2012
  1. @erasertwo
Commits on May 9, 2012
  1. @erasertwo

    Merge remote-tracking branch 'remotes/upstream/master'

    erasertwo authored
    Conflicts:
    	library/Zend/Db/Adapter/Driver/Mysqli/Result.php
This page is out of date. Refresh to see the latest.
View
16 library/Zend/Db/Adapter/Driver/Mysqli/Result.php
@@ -91,8 +91,7 @@ class Result implements \Iterator, ResultInterface
/**
* @var mixed
- */
- protected $generatedValue = null;
+ */ protected $generatedValue = null;
/**
* Initialize
@@ -111,6 +110,11 @@ public function initialize($resource, $generatedValue)
$this->resource = $resource;
$this->generatedValue = $generatedValue;
$this->mode = ($this->resource instanceof \mysqli_stmt) ? self::MODE_STATEMENT : self::MODE_RESULT;
+
+ if ($this->mode == self::MODE_STATEMENT) {
+ // must be stored, otherwise fetched resulting rows are lost
+ $this->resource->store_result();
+ }
return $this;
}
@@ -269,11 +273,7 @@ public function rewind()
{
$this->currentComplete = false;
$this->position = 0;
- if ($this->resource instanceof \mysqli_stmt) {
- //$this->resource->reset();
- } else {
- $this->resource->data_seek(0); // works for both mysqli_result & mysqli_stmt
- }
+ $this->resource->data_seek(0);
}
/**
* Valid
@@ -306,4 +306,4 @@ public function getGeneratedValue()
{
return $this->generatedValue;
}
-}
+}
View
56 tests/Zend/DocBook/ClassParserTest.php
@@ -1,56 +0,0 @@
-<?php
-/**
- * Zend Framework (http://framework.zend.com/)
- *
- * @link http://github.com/zendframework/zf2 for the canonical source repository
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @package Zend_DocBook
- */
-
-namespace ZendTest\DocBook;
-
-use PHPUnit_Framework_TestCase as TestCase;
-use Zend\DocBook\ClassParser;
-use Zend\Code\Reflection\ClassReflection;
-
-/**
- * @category Zend
- * @package Zend_DocBook
- * @subpackage UnitTests
- */
-class ClassParserTest extends TestCase
-{
- /** @var ClassReflection */
- public $class;
- /** @var ClassParser */
- public $parser;
-
- /**
- * Sets up the fixture, for example, open a network connection.
- * This method is called before a test is executed.
- *
- * @return void
- */
- public function setUp()
- {
- $this->class = new ClassReflection(new TestAsset\ParsedClass());
- $this->parser = new ClassParser($this->class);
- }
-
- public function testIdShouldBeNormalizedNamespacedClass()
- {
- $id = $this->parser->getId();
- $this->assertEquals('zend-test.doc-book.test-asset.parsed-class', $id);
- }
-
- public function testRetrievingMethodsShouldReturnClassMethodObjects()
- {
- $methods = $this->parser->getMethods();
-
- $this->assertEquals(count($this->class->getMethods(\ReflectionMethod::IS_PUBLIC)), count($methods));
- foreach ($methods as $method) {
- $this->assertInstanceOf('Zend\DocBook\ClassMethod', $method);
- }
- }
-}
View
67 tests/Zend/DocBook/TestAsset/ParsedClass.php
@@ -1,67 +0,0 @@
-<?php
-/**
- * Zend Framework (http://framework.zend.com/)
- *
- * @link http://github.com/zendframework/zf2 for the canonical source repository
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @package Zend_DocBook
- */
-
-namespace ZendTest\DocBook\TestAsset;
-
-use Zend\Loader\PluginClassLoader;
-
-/**
- * Class parsed by tests to get metadata for DocBook generation
- *
- * @category Zend
- * @package Zend_DocBook
- * @subpackage UnitTests_TestAsset
- */
-class ParsedClass
-{
- /**
- * short action1 method description
- *
- * Long description for action1
- *
- * @param string $arg1
- * @param bool $arg2
- * @param null|array $arg3
- * @return float
- */
- public function action1($arg1, $arg2, $arg3 = null)
- {
- }
-
- /**
- * action2
- *
- * Long description for action2
- *
- * @param null|PluginClassLoader $loader
- * @return ParsedClass
- */
- public function action2(PluginClassLoader $loader = null)
- {
- }
-
- /**
- * A camel-cased method name
- *
- * @return void
- */
- public function camelCasedMethod()
- {
- }
-
- /**
- * A method that the class parser should not aggregate
- *
- * @return void
- */
- protected function shouldNotAggregate()
- {
- }
-}
Something went wrong with that request. Please try again.