[nycphp-talk] PHP/MySQL environment problem??
paulcheung at tiscali.co.uk
Mon Mar 3 15:22:15 EST 2008
Can't believe I wrote Linus instead of Linux. Anyway, you are correct the
application is working under windows.
----- Original Message -----
From: "David Krings" <ramons at gmx.net>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Monday, March 03, 2008 6:13 PM
Subject: Re: [nycphp-talk] PHP/MySQL environment problem??
> PaulCheung wrote:
> I looked over the code and a few things struck me odd (which doesn't mean
> they are wrong!).
> You add this between each handful of lines without adding any informative
> comment. I'd remove those slashes and make the code easier to read - or
> even better add commentary.
>> @ $cps; //Current Page Starting row number
>> @ $lps; //Last Page Starting row number
>> @ $rpp; //Records Per Page
> I have no idea what the significance of these lines is. The @ is usually
> used to suppress error message output (IMHO a bad idea), but the statement
> (or lack thereof) doesn't do anything.
>> $q="SELECT SQL_CALC_FOUND_ROWS *
>> FROM tr_test_record
>> WHERE $access = tr_access";
>> $rs=mysql_query($q) or die(mysql_error());
>> $q0="Select FOUND_ROWS()";
> When you run the query in the MySQL query editor, how many rows does MySQL
> I always burn extra cycles and read the query results in a loop and
> increase a counter. All the MySQL functions that return a count do that
> for the last query run under the current connection, which may or may not
> be the last query that your code ran.
> I am not that familiar with all the SQL keywords, but it strikes me that
> SQL_CALC_FOUND_ROWS returns already the count that you are looking for,
> which is one result row. So counting that result later on will always be
> I rather have some of the SQL epxerts chime in here as I quickly move into
> an area that I have no clue about.
>> $rs0=mysql_query($q0) or die(mysql_error());
>> $nr0 = $row0["FOUND_ROWS()"]; //Number of rows found without LIMIT in
> As mentioned above, I run a plain simple select query and increase a
> counter while looping through the results returned. May not be as elegant
> and efficient, but works reliably. I just don't gtee away from thinking
> that SELECT SQL_CALC_FOUND_ROWS * FROM tr_test_record WHERE $access =
> tr_access doesn't return what you expect it should (as far as I understand
> it thsi already counts the rows that would be returned when running the
> query without SQL_CALC_FOUND_ROWS). Plug that into the query browser and
> see what happens. My uneducated guss is that you basically count how many
> row counts (not rows!!!) there were in the last query, which should always
> be 1. But then again, you say it works on Windoze....
> New York PHP Community Talk Mailing List
> NYPHPCon 2006 Presentations Online
> Show Your Participation in New York PHP
More information about the talk