Source for file number.php

Documentation is available at number.php

  1. <?php
  2. /**
  3.  * @package     FrameworkOnFramework
  4.  * @subpackage  model
  5.  * @copyright   Copyright (C) 2010 - 2012 Akeeba Ltd. All rights reserved.
  6.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  7.  */
  8. // Protect from unauthorized access
  9. defined('_JEXEC'or die;
  10.  
  11. /**
  12.  * FrameworkOnFramework model behavior class
  13.  *
  14.  * @package  FrameworkOnFramework
  15.  * @since    2.1
  16.  */
  17. {
  18.     /**
  19.      * The partial match is mapped to an exact match
  20.      *
  21.      * @param   mixed  $value  The value to compare to
  22.      *
  23.      * @return  string  The SQL where clause for this search
  24.      */
  25.     public function partial($value)
  26.     {
  27.         return $this->exact($value);
  28.     }
  29.  
  30.     /**
  31.      * Perform a between limits match. When $include is true
  32.      * the condition tested is:
  33.      * $from <= VALUE <= $to
  34.      * When $include is false the condition tested is:
  35.      * $from < VALUE < $to
  36.      *
  37.      * @param   mixed    $from     The lowest value to compare to
  38.      * @param   mixed    $to       The higherst value to compare to
  39.      * @param   boolean  $include  Should we include the boundaries in the search?
  40.      *
  41.      * @return  string  The SQL where clause for this search
  42.      */
  43.     public function between($from$to$include true)
  44.     {
  45.         if ($this->isEmpty($from|| $this->isEmpty($to))
  46.         {
  47.             return '';
  48.         }
  49.  
  50.         $extra '';
  51.  
  52.         if ($include)
  53.         {
  54.             $extra '=';
  55.         }
  56.  
  57.         $sql '((' $this->getFieldName(' >' $extra ' ' $from ') AND ';
  58.         $sql .= '(' $this->getFieldName(' <' $extra ' ' $to '))';
  59.  
  60.         return $sql;
  61.     }
  62.  
  63.     /**
  64.      * Perform an outside limits match. When $include is true
  65.      * the condition tested is:
  66.      * (VALUE <= $from) || (VALUE >= $to)
  67.      * When $include is false the condition tested is:
  68.      * (VALUE < $from) || (VALUE > $to)
  69.      *
  70.      * @param   mixed    $from     The lowest value of the excluded range
  71.      * @param   mixed    $to       The higherst value of the excluded range
  72.      * @param   boolean  $include  Should we include the boundaries in the search?
  73.      *
  74.      * @return  string  The SQL where clause for this search
  75.      */
  76.     public function outside($from$to$include false)
  77.     {
  78.         if ($this->isEmpty($from|| $this->isEmpty($to))
  79.         {
  80.             return '';
  81.         }
  82.  
  83.         $extra '';
  84.  
  85.         if ($include)
  86.         {
  87.             $extra '=';
  88.         }
  89.  
  90.         $sql '((' $this->getFieldName(' <' $extra ' ' $from ') AND ';
  91.         $sql .= '(' $this->getFieldName(' >' $extra ' ' $to '))';
  92.  
  93.         return $sql;
  94.     }
  95.  
  96.     /**
  97.      * Perform an interval match. It's similar to a 'between' match, but the
  98.      * from and to values are calculated based on $value and $interval:
  99.      * $value - $interval < VALUE < $value + $interval
  100.      *
  101.      * @param   integer|float $value     The center value of the search space
  102.      * @param   integer|float $interval  The width of the search space
  103.      * @param   boolean        $include   Should I include the boundaries in the search?
  104.      *
  105.      * @return  string  The SQL where clause
  106.      */
  107.     public function interval($value$interval$include true)
  108.     {
  109.         if ($this->isEmpty($value))
  110.         {
  111.             return '';
  112.         }
  113.  
  114.         $from $value $interval;
  115.         $to $value $interval;
  116.  
  117.         $extra '';
  118.  
  119.         if ($include)
  120.         {
  121.             $extra '=';
  122.         }
  123.  
  124.         $sql '((' $this->getFieldName(' >' $extra ' ' $from ') AND ';
  125.         $sql .= '(' $this->getFieldName(' <' $extra ' ' $to '))';
  126.  
  127.         return $sql;
  128.     }
  129. }

Documentation generated on Tue, 19 Nov 2013 15:09:40 +0100 by phpDocumentor 1.4.3