PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Logiciels d'hébergement > mailing.database.mysql > found_rows() everytime returns 1
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
found_rows() everytime returns 1

Réponse
 
LinkBack Outils de la discussion
Vieux 03/05/2006, 17h11   #1
andrea azzini
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut found_rows() everytime returns 1

hi to all
I use this query
SELECT SQL_CALC_FOUND_ROWS * FROM prods LIMIT 100,10;

I'd like to know how many rows this query returns without limit, but
using this
select FOUND_ROWS();
the result is everytime 1

You know why?
No other query are processed before the found_rows().
Thanks

--
Andrea

  Réponse avec citation
Vieux 04/05/2006, 04h58   #2
Jeach!
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: found_rows() everytime returns 1

Not an answer to your question, but I figured that I'd try and run it
on my server... here is my results.

I'm using: mysql Ver 12.22 Distrib 4.0.24, for pc-linux-gnu (x86_64)

I ran all of these queries in this exact sequence:

If I run 'select * from client;' I get 264 rows
If I run 'select found_rows();' I get the correct value of 264
If I run 'select * from client limit 100,10;' I will get 10 rows
If I run 'select found_rows();' I erroneously get 110

So I guess its pretty much broken... I'll stay away from it!

Jeach!

  Réponse avec citation
Vieux 04/05/2006, 08h18   #3
andrea azzini
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: found_rows() everytime returns 1

You haven't use the SQL_CALC_FOUND_ROWS.
In the manual you can find "If the preceding SELECT statement does not
include the SQL_CALC_FOUND_ROWS option, then FOUND_ROWS() may return a
different result when LIMIT is used than when it is not."
If you can, try with this option.

p.s. i use on my server mysql 5.0.18
--
Andrea

  Réponse avec citation
Vieux 04/05/2006, 09h28   #4
andrea azzini
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: found_rows() everytime returns 1

mmmhhhh
I ran the queries using the MySQL Query Browser software
(http://www.mysql.com/products/tools/query-browser/)
and the result of found_rows was 1.
I ran the two queries above in a php page and the count of rows was
correct. I have lost many time for this problem

--
Andrea

  Réponse avec citation
Vieux 04/05/2006, 09h35   #5
andrea azzini
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: found_rows() everytime returns 1

mmmhhhh
I ran the queries using the MySQL Query Browser software
(http://www.mysql.com/products/tools/query-browser/)
and the result of found_rows was 1.
I ran the two queries above in a php page and the count of rows was
correct. I have lost many time for this problem

--
Andrea

  Réponse avec citation
Vieux 04/05/2006, 11h06   #6
andrea azzini
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: found_rows() everytime returns 1

mmmhhhh
I ran the queries using the MySQL Query Browser software
(http://www.mysql.com/products/tools/query-browser/)
and the result of found_rows was 1.
I ran the two queries above in a php page and the count of rows was
correct. I have lost many time for this problem

--
Andrea

  Réponse avec citation
Vieux 04/05/2006, 17h36   #7
Bill Karwin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: found_rows() everytime returns 1

andrea azzini wrote:
> I ran the queries using the MySQL Query Browser software
> (http://www.mysql.com/products/tools/query-browser/)
> and the result of found_rows was 1.


MySQL Query Browser opens a new connection for each statement you
execute. The value returned by FOUND_ROWS() is relevant only during the
current connection. So there is no way to use this function in MySQL
Query Browser; you must use the command-line tool 'mysql'.

FWIW, the same issue happens when trying to use other session-dependent
features in MySQL Query Browser, such as LAST_INSERT_ID() and user
variables.

Regards,
Bill K.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h30.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11653 seconds with 15 queries