Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

SmartyPaginate and Wildcard Queries

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
caliman
Smarty Regular


Joined: 25 Aug 2006
Posts: 49
Location: Pt. Richmond, CA

PostPosted: Tue Oct 31, 2006 10:12 pm    Post subject: SmartyPaginate and Wildcard Queries Reply with quote

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
View user's profile Send private message Visit poster's website
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Tue Oct 31, 2006 11:04 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caliman
Smarty Regular


Joined: 25 Aug 2006
Posts: 49
Location: Pt. Richmond, CA

PostPosted: Tue Oct 31, 2006 11:44 pm    Post subject: Reply with quote

I was going a different route with mysql_num_rows. Yours is much easier and works. Wink

Thank you. Smile
Back to top
View user's profile Send private message Visit poster's website
LukasKK
Smarty n00b


Joined: 13 Mar 2007
Posts: 3

PostPosted: Mon Mar 19, 2007 4:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
LukasKK
Smarty n00b


Joined: 13 Mar 2007
Posts: 3

PostPosted: Mon Mar 19, 2007 4:27 pm    Post subject: Reply with quote

Ok i know what happened when i use SmartyPaginate::disconnect(); Limit receive -1 don’t ask my way Embarassed and that was wrong because i should use SmartyPaginate::reset(); and when i do that everything back to normal Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP