473,775 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6453
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
4941
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 a Python native datatype? I have looked in the docs and seen there is a decode/encode method but how do I do this? Hope you can help.
2
3792
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 directory,
12
2491
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 out until Python 2.5? 2. What's the difference between sqlite and pysqlite? Do you need both, just one, or is one an older version of the same thing? 3. What's the difference between the command line program called sqlite3
3
3602
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 still have a problem. Sqlite does not appear to be my system: Traceback (most recent call last):
10
7563
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 = sqlite_open("mytest.db", 0666, $sqlite_error);
8
3416
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 installed sqlite.org/sqlite-3.5.4.tar.gz, and... 2. used "--with-sqlite --disable-pdo", but it fails.
3
275
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 is completely independent of the sqlite build. In other words, if your sqlite build supports full text searching you can use it through the python sqlite wrapper (that is part of the stdlib) and if it doesn't then not. This is true for any sqlite...
8
18155
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 sqlite2 drivers but then gives a "could not find driver" exception. Any help is greatly appreciated. Also, I am concerned if PDO for sqlite is widely supported by hosting companies, any input or opinions on that? <?php...
20
3973
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 using a sun machine (I normally use linux machines) and place this in my lunix home account would I be able to use python and sqlite? Any thoughts? I know its a bit of a stretch ...
0
10107
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10048
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6718
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4017
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.