Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8688623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:25:00+00:00 2026-06-12T23:25:00+00:00

So I’m using the (totally awesome) Cake DC Search plugin. Among other things, I

  • 0

So I’m using the (totally awesome) Cake DC Search plugin. Among other things, I want to have a ‘min’ and ‘max’ input, and search for records where ‘amount’ is within ‘min’ and ‘max’, if both are set, or greater-than/less-than min/max if only one is set.

I’ve got it working – the only problem is that the condition is being included twice in the SQL query. It’s pretty obvious why… here’s my model code:

public $filterArgs = array(
    'range_min' => array('type' => 'query', 'method' => 'findByAmountRange'),
    'range_max' => array('type' => 'query', 'method' => 'findByAmountRange'),
    // Other rules go here
);


public function findByAmountRange($data = array()) {
    // Returns a condition something like 'Model.amount BETWEEN 1 and 100'
}

So because both the ‘range_min’ and ‘range_max’ keys of $filterArgs both use the same method (findByAmountRange), then the condition is being included twice.

So, there are three solutions:

  1. Don’t worry about it, let the condition be there twice

  2. Create a instance variable in the model, like findByAmountRangeHasBeenCalled, and set it true the first time the method is called, so we know not to call it again in future

  3. Find a more elegant solution. Does the Search plugin have any way to deal with this? Can you set it to make two fields share a common filterArgs method, so that it only gets called once?

Thanks in advance.

PS – I know the test cases for the Search Plugin include a ‘make range condition’ example, but that’s not what I want – I want two fields, with the user able to input into both of them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:25:01+00:00Added an answer on June 12, 2026 at 11:25 pm

    OK, so it doesn’t look like I’ll get a proper answer. So, I’ve gone for option 1 – just leaving the duplicate condition in the query. Apparently MySQL will run a query optimiser prior to executing, and remove the duplicate condition, and so it won’t affect speed in any significant way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.