ezResults gets weird with LIMIT

Hi all,

I hope this hasn't been discussed here already, at least I couldn't find it with the site search function.

My query:

SELECT * FROM anytable LIMIT 10

Causes the following error with ez_results.smarty.php:

Warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0,10' at line 1 in c:\php\includes\ezSQL\ez_sql_mysql.php on line 175

After tinkering a while with this problem I noticed that this will not happen when using the plain ez_sql_mysql.php (so $db->get_results($q, ARRAY_A) works nicely) but only when using the mentioned ez_results.smarty.php ($ezr->query($q, ARRAY_A)).

Out of curiosity I checked what kind of query the ezResults was trying to run with ezSQL ($db->last_query) and here's what I found:

select distinct * from anytable limit 10 LIMIT 0,10

-- so the additional "LIMIT 0,10" messes up the whole thing!

I know it's kinda silly to use the LIMIT with ezResults as it's supposed to do that for you -- but I guess there could be a little more descriptive error message for this. Also, by searching the forums here I found out that this thing _might_ relate to some problems people have been having (http://www.jvmultimedia.com/portal/node/12).

Or is this just me rambling for nothing... ;)

Anyway, thanks for the ezResults & ezSQL -- they have really made my days ezier :)

PS. If you happen to want to know what I was doing in the first place when I found this thing, here's the story: I have a "picker" of customers where the user can search for customers with strings. However, when the page is first loaded and there's no text string to search yet, I want the user to see last 10 customers that were recently used in orders -- so my query is either:


$q = "SELECT * FROM customer c WHERE c.lname LIKE 'lname%' ..."

or, if there's no text string to search with:


$q = "SELECT * FROM customer ORDER BY last_purchase LIMIT 10"