|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18253 ADO Function Execute() doesn't return right amount of affected rows
Submitted: 2002-07-09 19:09 UTC Modified: 2002-07-17 18:48 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mkools at euronet dot nl Assigned:
Status: Not a bug Package: COM related
PHP Version: 4.2.1 OS: Windows 2000 Pro SP2
Private report: No CVE-ID: None
 [2002-07-09 19:09 UTC] mkools at euronet dot nl
I'm currently in the process of writing a wrapper class to connect through ADO with an MS Access database. The whole class works, except for one thing: I can't get the amound of affected records of an insert, update or delete statement.
What I have now is this:
    $Vrows = new VARIANT( 0, VT_I4|VT_BYREF);
    $this->QueryResult = @$this->Link->Execute( $inQuery, $Vrows);
    $this->AffectedRows = $Vrows->value;

Explaination: QueryResult will be my RecordSet, Link is the ADO Connection object, inQuery is the query itself and AffectedRows will hold the amount of affected records by the query.
But this seems to return the value 7779424 in all cases (even with select statements).
The second things I've tried is:
    $this->QueryResult = @$this->Link->Execute( $inQuery, &$this->AffectedRows);

But that doesn't do anything with the AffectedRows variable. It keeps holding the value of what I put in it previously (I default it to -1).
Is this a bug, or am I doing things totally wrong? I found the latter syntax on some other places on the web, so either those aren't working either or I'm forgetting something...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-09 19:11 UTC] mkools at euronet dot nl
Forgot this in the original post: The queries itself do seem to work fine, so it's only the affectedrows which isn't working.
 [2002-07-17 18:48 UTC]
your code is wrong, try 

$Vrows = new VARIANT();

$Vrows->value will most likely -1 then as almost no ADODB provider returns the right count.

alternatively you can try using $this->QueryResult->RecordCount

 [2002-07-17 20:18 UTC] mkools at euronet dot nl
You were right, my code was wrong indeed. I did $VRows = new VARIANT(); and then called the Execute function with &$VRows .. and that did work. But when I searched for a solution on the web, no site suggested this solution. Is it perhaps because of it's changed in version 4.2.1? Or is all the other code wrong too then?
But many thanks!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 05:01:30 2024 UTC