odbc_num_rows always returns -1

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
princessAlbert
Forum Newbie
Posts: 2
Joined: Tue May 13, 2003 4:38 pm
Location: London

odbc_num_rows always returns -1

Post by princessAlbert »

hi..
in the documentation it says this will happen "with many drivers"; anyone know what these are and how to resolve this?
failing that, all i need is a way to retrieve a recordcount without having to loop over the query result..
ta[/i]
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

can you give some more detail?



btw isn't Albert a guys name? =P
princessAlbert
Forum Newbie
Posts: 2
Joined: Tue May 13, 2003 4:38 pm
Location: London

Post by princessAlbert »

hi.. more detail.. ok:

i am using PHP 4.3.1

here's my query stuff:

$dsn="ds";
$conn=odbc_connect($dsn, "u", "pw");
$query="select * from somewhere";
$result=odbc_Exec($conn, $query);

now when i do this:

while(odbc_fetch_row($result))
{ echo "test<br>";
}

i get a list which proves records were found, but when i do this:

echo odbc_num_rows($result);

i get -1. all i want is to find the recordcount!!!

thanks



yes it is; i can't help it; i was born into it :P
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

the user contributed notes at http://www.php.net/manual/en/function.odbc-num-rows.php offer some workarounds
Post Reply