473,387 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SQLite PDO numRows problem

Kim
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).
Nov 20 '07 #1
4 6436
On Tue, 20 Nov 2007 16:31:28 +0100, Kim <ki*****@gmail.comwrote:
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
Nov 20 '07 #2
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]
Nov 21 '07 #3
Kim
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.dewrote:
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]
Nov 30 '07 #4
On Fri, 30 Nov 2007 13:40:23 +0100, Kim <ki*****@gmail.comwrote:
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
Nov 30 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: bolly | last post by:
Hi, I've been putting Python data into a sqlite3 database as tuples but when I retrieve them they come back as unicode data e.g 'u(1,2,3,4)'.How can I change it back to a tuple so I can use it as...
2
by: Christian Stooker | last post by:
Part one: ====== Hi ! I want to use SQLite database like the FireBird database: with big isolation level. What's that meaning ? I have an application that periodically check some input...
12
by: John Salerno | last post by:
I've been looking around and reading, and I have a few more questions about SQLite in particular, as it relates to Python. 1. What is the current module to use for sqlite? sqlite3? or is that not...
3
by: ricardo.turpino | last post by:
Hi, I've installed Mac Python 2.5. I'm running Mac OS X 10.4.10 on a Macbook 1.83GHz. I though that the python sqlite library was installed by default as part of Mac Python 2.5, however, I...
10
by: Luigi | last post by:
Hello all! I'm a newbie in PHP. I have written a short script that tries to update a SQLite database with the user data. It is pretty simple, something like this: <?php $sqlite =...
8
by: Gilles Ganault | last post by:
Hello I need to compile PHP5 with SQLite statically and without PDO. I don't need DB-independence, so it's fine using sqlite_*() functions instead of PDO. 1. I've downloaded, compiled, and...
3
by: Daniel Fetchinson | last post by:
Does Python 2.5.2's embedded SQLite support full text searching? Sqlite itself is not distributed with python. Only a python db api compliant wrapper is part of the python stdlib and as such it...
8
by: john6630 | last post by:
I am trying to get PDO for sqlite to work on my localhost system. I have modified the PHP5.ini file as shown below and run the following PHP script. As stated below, it reports the mssql, mysql and...
20
by: timotoole | last post by:
Hi all, On a (sun) webserver that I use, there is python 2.5.1 installed. I'd like to use sqlite3 with this, however sqlite3 is not installed on the webserver. If I were able to compile sqlite...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.