From: Stephen on
I am switching to PDO and can't find an equivalent to mysql_num_rows.

Am I missing something silly?

Or is there a change of thinking needed for PDO?

How should I determine how many rows a query returned?

Thanks
Stephen
From: Kevin Waterson on
This one time, at band camp, Stephen <stephen-d(a)rogers.com> wrote:

> I am switching to PDO and can't find an equivalent to mysql_num_rows.
>
> Am I missing something silly?
>
> Or is there a change of thinking needed for PDO?
>
> How should I determine how many rows a query returned?

PDO returns an array, sizeof/count will get you home

Kevin
http://phpro.org
From: Stephen on
Kevin Waterson wrote:
>> I am switching to PDO and can't find an equivalent to mysql_num_rows.
>>
>> Am I missing something silly?
>>
>> Or is there a change of thinking needed for PDO?
>>
>> How should I determine how many rows a query returned?
>>
>
> PDO returns an array, sizeof/count will get you home
>
I would like to know how many rows I am working with before starting to
fetch.

Also fetchall, does not seem to have a style that returns each column
value just once. I see this ugly thing in the manual:

Fetch all of the remaining rows in the result set:
Array
(
[0] => Array
(
[NAME] => pear
[0] => pear
[COLOUR] => green
[1] => green
)

[1] => Array
(
[NAME] => watermelon
[0] => watermelon
[COLOUR] => pink
[1] => pink
)

)

If I could get the column offsets only, without the column names I would be very happy.

Stephen



From: "Bastien Koert" on
On Sun, Jul 13, 2008 at 10:30 AM, Stephen <stephen-d(a)rogers.com> wrote:

> Kevin Waterson wrote:
>
>> I am switching to PDO and can't find an equivalent to mysql_num_rows.
>>>
>>> Am I missing something silly?
>>>
>>> Or is there a change of thinking needed for PDO?
>>>
>>> How should I determine how many rows a query returned?
>>>
>>>
>>
>> PDO returns an array, sizeof/count will get you home
>>
>>
> I would like to know how many rows I am working with before starting to
> fetch.
>
> Also fetchall, does not seem to have a style that returns each column value
> just once. I see this ugly thing in the manual:
>
> Fetch all of the remaining rows in the result set:
> Array
> (
> [0] => Array
> (
> [NAME] => pear
> [0] => pear
> [COLOUR] => green
> [1] => green
> )
>
> [1] => Array
> (
> [NAME] => watermelon
> [0] => watermelon
> [COLOUR] => pink
> [1] => pink
> )
>
> )
>
> If I could get the column offsets only, without the column names I would be
> very happy.
>
> Stephen
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
http://ca3.php.net/manual/en/pdostatement.rowcount.php

--

Bastien

Cat, the other other white meat
From: Stephen on
Bastien Koert wrote:
> On Sun, Jul 13, 2008 at 10:30 AM, Stephen <stephen-d(a)rogers.com> wrote:
>
>
>> Kevin Waterson wrote:
>>
>>
>>> I am switching to PDO and can't find an equivalent to mysql_num_rows.
>>>
>>>> Am I missing something silly?
>>>>
>>>> Or is there a change of thinking needed for PDO?
>>>>
>>>> How should I determine how many rows a query returned?
>>>>
>>>>
>>>>
>>> PDO returns an array, sizeof/count will get you home
>>>
>>>
>>>
>> I would like to know how many rows I am working with before starting to
>> fetch.
>>
>> Also fetchall, does not seem to have a style that returns each column value
>> just once. I see this ugly thing in the manual:
>>
>> Fetch all of the remaining rows in the result set:
>> Array
>> (
>> [0] => Array
>> (
>> [NAME] => pear
>> [0] => pear
>> [COLOUR] => green
>> [1] => green
>> )
>>
>> [1] => Array
>> (
>> [NAME] => watermelon
>> [0] => watermelon
>> [COLOUR] => pink
>> [1] => pink
>> )
>>
>> )
>>
>> If I could get the column offsets only, without the column names I would be
>> very happy.
> http://ca3.php.net/manual/en/pdostatement.rowcount.php
>
>

This is only good for updates, inserts and deletes.<br>

I am just doing a select.

Stephen<br>