Re: [phplib] Problem in num_rows() From: Alexander Aulbach (ssilk <email protected>)
Date: 07/13/00

On Thu, 13 Jul 2000, NickM wrote:

}In num_rows, this is the logic used:
} $from_pos = strpos(strtoupper($this->lastQuery),"FROM");
} $q = "SELECT count(*) ". substr($this->lastQuery, $from_pos);
}
}This does not always work and I have found with some complex queries it
}returns the wrong value. I have now changed it in mine to simply:
} $q = "select count(*) from (".$this->lastQuery.")";
}
}Is there any reason this might not work correctly, as far as I can see the
}first one seems overkill. I guess it is for making it faster running on the
}db, but does it? I mean it is probably more overhead to have all the calls
}to strpos(), strtoupper(), substr().

I tried to remember why I used this method to count the rows, but I can't
although I'm nearly sure, that I tried the above construct before I came
to the other reason...

Your method is a count on the subselected number of rows. I would say, the
time this needs depends very strong on your lastQuery and how it could be
cached in the memory. I think, for very big results this could be slower
than the direct method - but I'm of course not sure, Oracle is like an
oracle - you can puzzle out what it will do. :>

I would suggest some time measurements. Perhaps you can use my new time
measurent-functions in strings2.inc. :-)) Sorry I coulnd't test it, cause
I don't need to have Oracle installed here any more (and I'm very glad
about that :-))

-- 

SSilk - Alexander Aulbach - Herbipolis/Frankonia Minoris - (0931)22032

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>