SQLite PDO numRows problem

This is a discussion on SQLite PDO numRows problem within the PHP Language forums, part of the PHP Programming Forums category; I keep getting "function not defined" when trying to get a result count on my queries ("numRows()&...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-20-2007
Kim
 
Posts: n/a
Default SQLite PDO numRows problem

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 ?


I followed example 2332 on PHP.net, but no luck. (http://www.php.net/
manual/en/function.sqlite-num-rows.php)
Im using PHP 5.1.4 and SQLite Library 3.2.8undefined (PDO).
Reply With Quote
  #2 (permalink)  
Old 11-20-2007
Rik Wasmus
 
Posts: n/a
Default Re: SQLite PDO numRows problem

On Tue, 20 Nov 2007 16:31:28 +0100, Kim <kimslot@gmail.com> wrote:

> 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 ?
>
>
> I followed example 2332 on PHP.net, but no luck. (http://www.php.net/
> manual/en/function.sqlite-num-rows.php)
> Im using PHP 5.1.4 and SQLite Library 3.2.8undefined (PDO).


PDO? ->
http://nl2.php.net/manual/en/functio...t-rowCount.php

NOT PDO? ->
It should work as long as either you use $object->numRows() and $object is
of the class SQLiteResult (var_dump() the thing to find out), or with
sqlite_num_rows($result) where $result is a resource (once again,
var_dump() the thing to find out).
--
Rik Wasmus
Reply With Quote
  #3 (permalink)  
Old 11-22-2007
Oliver Grätz
 
Posts: n/a
Default Re: SQLite PDO numRows problem

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]
Reply With Quote
  #4 (permalink)  
Old 11-30-2007
Kim
 
Posts: n/a
Default Re: SQLite PDO numRows problem

I ended up with using 2 queries, first one giving only a count result
(FetchColumn) and the second to give the actual content (loop with
Fetch).

I never got PHP to create a SQLite PDO object, and I had enabled both
required dlls (php_pdo.dll and php_pdo_sqlite.dll) in php.ini.

OLLi: Exactly how am I not using non-PDO functions ? numRows() is
listed as a PDO function on www.php.net.

On Nov 22, 12:24 am, Oliver Grätz <oliver.gra...@gmx.de> wrote:
> 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]


Reply With Quote
  #5 (permalink)  
Old 11-30-2007
Rik Wasmus
 
Posts: n/a
Default Re: SQLite PDO numRows problem

On Fri, 30 Nov 2007 13:40:23 +0100, Kim <kimslot@gmail.com> wrote:
> I ended up with using 2 queries, first one giving only a count result
> (FetchColumn) and the second to give the actual content (loop with
> Fetch).
>
> I never got PHP to create a SQLite PDO object, and I had enabled both
> required dlls (php_pdo.dll and php_pdo_sqlite.dll) in php.ini.
>
> OLLi: Exactly how am I not using non-PDO functions ? numRows() is
> listed as a PDO function on www.php.net.


Show us the URL.... it isn't.
<http://www.php.net/manual/en/ref.pdo.php>
<http://www.php.net/manual/en/ref.pdo-sqlite.php>
--
Rik Wasmus
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:50 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0