You are here: Re: SQLite PDO numRows problem « PHP Programming Language « IT news, forums, messages
Re: SQLite PDO numRows problem

Posted by Oliver Grδtz on 11/21/07 23:24

Kim schrieb:
> I keep getting "function not defined" when trying to get a result
> count on my queries ("numRows()") and dont see a bug report on PHP.net
> on this matter. And yes, my queries DO have results.
> Any idea why I get that message ?

First of all, you are using non-PDO functions in a PDO context. And
then, even rowCount won't help you because for most backend it only
tells you how many rows were AFFECTED by your query (INSERT, UPDATE,
....) not the number of rows that were RETURNED (SELECT). PDO does not
feature any numrows-capabilities, even if the backend does. You have to
resort to one of two solutions:

1. Use fetchAll() followed by count(). Be warned that this fetches ALL
of the query result into PHP meory which can cause serious performance
and/or memory problems for large result sets.

2. Use a COUNT(*) variant of your other query to get the number of
results. Once you work with large result sets you would have done
something like this anyway because you would start implementing some
kind of paging through the result.

OLLi

--
Hoshi: "Shouldn't we try to help them?"
T'Pol: "They don't want our help."
Hoshi: "How do you know?"
T'Pol: "They're Klingons."
[Enterprise]

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация