worldcomingtoanend Posted February 10, 2010 Share Posted February 10, 2010 ..odbc_num_rows always gives a result of -1 and i need something that can give me a result of 1. Thank you. Link to comment https://forums.phpfreaks.com/topic/191581-how-do-i-get-the-number-of-rows-in-php-odbc-without-using-odbc_num_rows/ Share on other sites More sharing options...
jskywalker Posted February 10, 2010 Share Posted February 10, 2010 from http://php.net/manual/en/function.odbc-num-rows.php: Two workarounds: 1. When you just need to verify that any rows returned from your query you can use select count(*) as cnt from table and then just get $row['cnt'] 2. When you need to actually loop through the records this function returns number of rows in the recordset if and only if you include ORDER BY clause in your query statement. so, it seems adding an 'ORDER BY' to your query might work Link to comment https://forums.phpfreaks.com/topic/191581-how-do-i-get-the-number-of-rows-in-php-odbc-without-using-odbc_num_rows/#findComment-1009924 Share on other sites More sharing options...
worldcomingtoanend Posted February 10, 2010 Author Share Posted February 10, 2010 from http://php.net/manual/en/function.odbc-num-rows.php: Two workarounds: 1. When you just need to verify that any rows returned from your query you can use select count(*) as cnt from table and then just get $row['cnt'] 2. When you need to actually loop through the records this function returns number of rows in the recordset if and only if you include ORDER BY clause in your query statement. so, it seems adding an 'ORDER BY' to your query might work thank you so much jskywalker that worked like a charm... Link to comment https://forums.phpfreaks.com/topic/191581-how-do-i-get-the-number-of-rows-in-php-odbc-without-using-odbc_num_rows/#findComment-1009926 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.