I am trying to get a pager_query to not return false. I have probably the simplest query you guys will ever see and I cannot get this one to work. I have the function working in another module (different sql) that i wrote. I have tried with select * from {node}; too and that doesn't work either. I cannot look at this page anymore so im moving on and asking for some help..

	$pagesize = 25;

	$sql = "SELECT * from {storefinder} order by sname;";
	$dbresult	= pager_query($sql, $pagesize);

any thoughts or suggestions are greatly appreciated.

Thanks guys

Comments

nevets’s picture

Someone recently had a similiar question and some pointed out the SQL keywords need to be all upper case so you might try

 $pagesize = 25;

$sql = "SELECT * FROM {storefinder} ORDER BY sname;";
$dbresult = pager_query($sql, $pagesize);
bmagistro’s picture

i would love to say that fixes it but still no go. I am about to build my own pager_query function that duplicates drupals and see where it is dieing.....unless someone has some great ideas...

edit:
of all the things to break it, the ; at the end seems to do it. I am not filing a bug report until someone else can confirm this?? or is it not worth filing one for this??

jmmec’s picture

Just curious why you have the ";" within your query? I don't know that this would cause a problem, but what happens if you remove it?

bmagistro’s picture

when it is removed it works. i add it out of habit to signal the end of a query. it is more common to use it with inserts and updates that are made up of multiple queries or return the last added id number.

bmagistro’s picture

SET @pos=0;SELECT *, @pos:=@pos+1 AS rnum, ( 3959 * acos( cos( radians('%f') ) * cos( radians( lat ) ) * cos( radians( lon ) - radians('%f') ) + sin( radians('%f') ) * sin( radians( lat ) ) ) ) AS distance FROM {storefinder} HAVING distance < '%d' ORDER BY distance

unless someone knows how to do the equivalent of row numbering in sql w/o that...

bmagistro’s picture

is there a hook that can be created so other events can be fired on a page change event?

rafhuys’s picture

Did you ever sort this out?
I want to update DB at that point.

Tnx