Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the numRows of aResultset #3

Open
rmarinleal opened this issue Feb 3, 2016 · 1 comment
Open

Problem with the numRows of aResultset #3

rmarinleal opened this issue Feb 3, 2016 · 1 comment

Comments

@rmarinleal
Copy link

Hello,

I'm using your adapter class sucessfully but I have a bug when reading de recordount of the Resulset

Making a simple test (provided by phalcon documentation)

$robots = Robots::find();
print_r($robots->count());

Return -1 but the resultset have 3 records

I think the problem is that you override the numRows function in your PdoSqlsrv Result Class and ommit the "select count(*)..." that phalcon do, but I'm not sure.

Here is a var_dump of the robots object:

object(Phalcon\Mvc\Model\Resultset\Simple)[52]
  protected '_result' => 
    object(Phalcon\Db\Result\PdoMssql)[54]
      protected '_connection' => 
        object(plugins\MSSQL\Adapter\Mssql)[48]
          protected '_type' => string 'sqlsrv' (length=6)
          protected '_dialectType' => string 'sqlsrv' (length=6)
          protected '_eventsManager' => null
          protected '_descriptor' => 
            array (size=6)
              ...
          protected '_dialect' => 
            object(plugins\MSSQL\Dialect\Mssql)[51]
              ...
          protected '_connectionId' => int 0
          protected '_sqlStatement' => null
          protected '_sqlVariables' => null
          protected '_sqlBindTypes' => null
          protected '_transactionLevel' => int 0
          protected '_transactionsWithSavepoints' => boolean false
          protected '_pdo' => 
            object(PDO)[49]
              ...
          protected '_affectedRows' => null
      protected '_result' => null
      protected '_fetchMode' => int 2
      protected '_pdoStatement' => 
        object(PDOStatement)[55]
          public 'queryString' => string 'SELECT "robots"."id", "robots"."name", "robots"."type", "robots"."year" FROM "robots"' (length=85)
      protected '_sqlStatement' => string 'SELECT "robots"."id", "robots"."name", "robots"."type", "robots"."year" FROM "robots"' (length=85)
      protected '_bindParams' => null
      protected '_bindTypes' => null
      protected '_rowCount' => int -1
  protected '_cache' => null
  protected '_isFresh' => boolean true
  protected '_pointer' => int 0
  protected '_count' => int -1
  protected '_activeRow' => null
  protected '_rows' => 
    array (size=3)
      0 => 
        array (size=4)
          'id' => string '8' (length=1)
          'name' => string 'Robotina' (length=8)
          'type' => string 'mechanical' (length=10)
          'year' => string '1972' (length=4)
      1 => 
        array (size=4)
          'id' => string '9' (length=1)
          'name' => string 'Astro Boy' (length=9)
          'type' => string 'mechanical' (length=10)
          'year' => string '1952' (length=4)
      2 => 
        array (size=4)
          'id' => string '10' (length=2)
          'name' => string 'Terminator' (length=10)
          'type' => string 'cyborg' (length=6)
          'year' => string '2029' (length=4)
  protected '_row' => null
  protected '_errorMessages' => null
  protected '_hydrateMode' => int 0
  protected '_model' => 
    object(Robots)[47]
      public 'id' => null
      public 'name' => null
      public 'year' => null
      public 'type' => null
      protected '_dependencyInjector' => 
        object(Phalcon\Di\FactoryDefault)[5]
          protected '_services' => 
            array (size=23)
              ...
          protected '_sharedInstances' => 
            array (size=7)
              ...
          protected '_freshInstance' => boolean false
          protected '_eventsManager' => null
      protected '_modelsManager' => 
        object(Phalcon\Mvc\Model\Manager)[43]
          protected '_dependencyInjector' => 
            object(Phalcon\Di\FactoryDefault)[5]
              ...
          protected '_eventsManager' => null
          protected '_customEventsManager' => null
          protected '_readConnectionServices' => null
          protected '_writeConnectionServices' => null
          protected '_aliases' => null
          protected '_hasMany' => null
          protected '_hasManySingle' => null
          protected '_hasOne' => null
          protected '_hasOneSingle' => null
          protected '_belongsTo' => null
          protected '_belongsToSingle' => null
          protected '_hasManyToMany' => null
          protected '_hasManyToManySingle' => null
          protected '_initialized' => 
            array (size=1)
              ...
          protected '_sources' => 
            array (size=1)
              ...
          protected '_schemas' => null
          protected '_behaviors' => null
          protected '_lastInitialized' => 
            &object(Robots)[47]
          protected '_lastQuery' => null
          protected '_reusable' => null
          protected '_keepSnapshots' => null
          protected '_dynamicUpdate' => null
          protected '_namespaceAliases' => null
      protected '_modelsMetaData' => null
      protected '_errorMessages' => null
      protected '_operationMade' => int 0
      protected '_dirtyState' => int 1
      protected '_transaction' => null
      protected '_uniqueKey' => null
      protected '_uniqueParams' => null
      protected '_uniqueTypes' => null
      protected '_skipped' => null
      protected '_related' => null
      protected '_snapshot' => null
  protected '_columnMap' => null
  protected '_keepSnapshots' => boolean false

Thanks!!

@woody712
Copy link

I have the same problem.

Pls see this https://www.php.net/manual/zh/pdostatement.rowcount.php

So I think I should change my connection type from 'dblib' to others.

I'm trying now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants