Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 07-18-2003, 05:23 PM   #1
richard
Confirmed User
 
Join Date: Feb 2001
Location: UK
Posts: 543
MYSQL Gurus.... i need adivce

I'm using mysql 4, and want to use the new FOUND_ROWS() to find out the number of rows the query would have returned if i did not use limit.

Lets say i have 100 members, and i want to display 10 of them per HTML page, so i'm doing something like:

SELECT SQL_CALC_FOUND_ROWS * from my_table LIMIT 0,10;

I then want to do a 2nd query,

SELECT FOUND_ROWS();

to get the total number of results for my first query. (ie, i get 10 results, and now know how many total results i have, hence the number of pages of results).

Would i be correct in thinking i should aquire a WRITE LOCK on the table before doing both SELECT queries? (my thinking being another process could perform another SELECT query on the table in between the first and second query, which would change the FOUND_ROWS() result...).

?

How otherwise would you suggest i do this?

Richard.
__________________
richard is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-18-2003, 05:35 PM   #2
NetRodent
Confirmed User
 
Join Date: Jan 2002
Location: In the walls of your house.
Posts: 3,985
You don't need to lock the tables. As long as you use the same connection for both queries you shouldn't have a problem.
__________________
"Every normal man must be tempted, at times, to spit on his hands, hoist the black flag, and begin slitting throats."
--H.L. Mencken
NetRodent is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.