|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
caliman Smarty Regular
Joined: 25 Aug 2006 Posts: 49 Location: Pt. Richmond, CA
|
Posted: Tue Oct 31, 2006 10:12 pm Post subject: SmartyPaginate and Wildcard Queries |
|
|
I am trying to use SmartyPaginate to help display search results. Any ideas why this fails or what the right syntax is?
Code: | $sql = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM domains WHERE domain LIKE '%" . PARTIAL_DOMAIN . "%' ORDER BY " . $order . " LIMIT %d,%d",SmartyPaginate::getCurrentIndex('domains'), SmartyPaginate::getLimit('domains'));
|
Warning: sprintf(): Too few arguments
It doesn't to like wildcards?
When I remove the '%' it does not choke. |
|
Back to top |
|
TGKnIght Smarty Junkie
Joined: 07 Sep 2005 Posts: 580 Location: Philadelphia, PA
|
Posted: Tue Oct 31, 2006 11:04 pm Post subject: |
|
|
It's probably because sprintf picks up the %' at the end of the wildcard to mean you were adding another value in there instead of literally using the %.
Anyway why don't you just make life easier on yourself and forget the sprintf()..
You can do the exact same thing in a much easier way (( especially considering you were adding in your CONSTANT using the method I'm about to show you ))
Code: |
$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM domains WHERE domain LIKE '%" . PARTIAL_DOMAIN . "%' ORDER BY " . $order . " LIMIT " .SmartyPaginate::getCurrentIndex('domains') .", ". SmartyPaginate::getLimit('domains');
|
_________________ Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template |
|
Back to top |
|
caliman Smarty Regular
Joined: 25 Aug 2006 Posts: 49 Location: Pt. Richmond, CA
|
Posted: Tue Oct 31, 2006 11:44 pm Post subject: |
|
|
I was going a different route with mysql_num_rows. Yours is much easier and works.
Thank you. |
|
Back to top |
|
LukasKK Smarty n00b
Joined: 13 Mar 2007 Posts: 3
|
Posted: Mon Mar 19, 2007 4:06 pm Post subject: |
|
|
Hi
this is my problem when i first use paging everything work ok then i try to use
SmartyPaginate::disconnect(id = 'mydata');
to delete data from Array and give array new data. In this moment my limit receive -1
so Code: | $_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM historia_towaru_pmt LIMIT %d,%d",
SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
print_R($_query); |
givse SELECT SQL_CALC_FOUND_ROWS * FROM historia_towaru_pmt LIMIT -1,20
can anyone explain my what happened. |
|
Back to top |
|
LukasKK Smarty n00b
Joined: 13 Mar 2007 Posts: 3
|
Posted: Mon Mar 19, 2007 4:27 pm Post subject: |
|
|
Ok i know what happened when i use SmartyPaginate::disconnect(); Limit receive -1 don’t ask my way and that was wrong because i should use SmartyPaginate::reset(); and when i do that everything back to normal |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|