jrCore_db_search_items and return_count

d.redaelli
d.redaelli
@dredaelli
11 years ago
9 posts
if i use jrCore_db_search_items function with return_count param to true and my records is over 10 items, the result is always 10 because it always append "LIMIT 10". If i want the number of records i need to set limit param to 999999.
It's a workaround that i don't like!
updated by @dredaelli: 07/21/14 01:05:52AM
michael
@michael
11 years ago
7,768 posts
so dont set the limit to 10.

Set the paginate to 10 and only show the first page.
d.redaelli
d.redaelli
@dredaelli
11 years ago
9 posts
michael:
so dont set the limit to 10.

Set the paginate to 10 and only show the first page.

how can i don't set the limit to 10? limit accept only values > 0!

I don't want show the first page, i want only the number of records that the JrCore_db_search_items find and with return_count param this doesn't works fine!
michael
@michael
11 years ago
7,768 posts
The return count will show the total number of items in the query you request.

So I suggested to make a query using page and pagebreak instead.

Check out these docs:
"{jrCore_list}"
http://www.jamroom.net/the-jamroom-network/documentation/development/89/jrcore-list

jrCore_list is just a wrapper for the search functionality that is available in the templates, so the same rules apply.

If you limit it to 10, you get 10.

If you pagebreak it at 10 then on page 2 you will get 11~20 etc. so if you dont include a pager to move to the next page, then you have all the results but only show 10 of them.

Its just one idea, im sure there are other ways to get there too.
SteveX
SteveX
@ultrajam
11 years ago
2,584 posts
@michael, I think d.redaelli only wants the count from a search, not the actual items:

function view_jrBlog_test($_post, $_user, $_conf)
{ $_sp = array( 'return_count' => true, 'limit' => 999999 ); $_rt = jrCore_db_search_items('jrBlog',$_sp); return $_rt; }
That will return the count of blog posts, if you remove the limit parameter it returns 10

@d.redaelli - as far as I know you do need to set a really high limit to get a count. Why don't you want to set a limit parameter, what makes it a problem?


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
brian
@brian
11 years ago
10,148 posts
The default "limit" is 10 - just set it really high (say 9999999) and you'll get a count of all.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
michael
@michael
11 years ago
7,768 posts
Cheers @stevex, glad you could understand.

If your just wanting a count, then I'd also add in the 'skip triggers' so you dont make all the other modules add in all the other stuff.
function view_jrBlog_test($_post, $_user, $_conf)
{ $_sp = array( 'return_count' => true, 'skip_triggers' => true, 'limit' => 999999 ); $_rt = jrCore_db_search_items('jrBlog',$_sp); return $_rt; }

Tags