Source for file field.php
Documentation is available at field.php
* @package FrameworkOnFramework
* @copyright Copyright (C) 2010 - 2012 Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
// Protect from unauthorized access
* FrameworkOnFramework model behavior class
* @package FrameworkOnFramework
* The column name of the table field
* The column type of the table field
* The alias of the table used for filtering
* The null value for this type
* @param JDatabaseDriver $db The database object
* @param object $field The field informations as taken from the db
* @param string $table_alias The table alias to use when filtering
public function __construct($db, $field, $table_alias =
false)
$this->name =
$field->name;
$this->type =
$field->type;
* Is it a null or otherwise empty value?
* @param mixed $value The value to test for emptiness
return ($value ===
$this->null_value) ||
empty($value);
* Returns the default search method for a field. This always returns 'exact'
* and you are supposed to override it in specialised classes. The possible
* values are exact, partial, between and outside, unless something
* different is returned by getSearchMethods().
* @see self::getSearchMethods()
* Return the search methods available for this field class,
$ignore =
array('isEmpty', 'getField', 'getFieldType', '__construct', 'getDefaultSearchMethod', 'getSearchMethods');
$class =
new ReflectionClass(__CLASS__
);
$methods =
$class->getMethods(ReflectionMethod::IS_PUBLIC);
foreach ($methods as $method)
* Perform an exact match (equality matching)
* @param mixed $value The value to compare to
* @return string The SQL where clause for this search
public function exact($value)
$value =
array_map(array($db, 'quote'), $value);
return $this->search($value, '=');
* Perform a partial match (usually: search in string)
* @param mixed $value The value to compare to
* @return string The SQL where clause for this search
abstract public function partial($value);
* Perform a between limits match (usually: search for a value between
* two numbers or a date between two preset dates). When $include is true
* the condition tested is:
* When $include is false the condition tested is:
* @param mixed $from The lowest value to compare to
* @param mixed $to The higherst value to compare to
* @param boolean $include Should we include the boundaries in the search?
* @return string The SQL where clause for this search
abstract public function between($from, $to, $include =
true);
* Perform an outside limits match (usually: search for a value outside an
* area or a date outside a preset period). When $include is true
* the condition tested is:
* (VALUE <= $from) || (VALUE >= $to)
* When $include is false the condition tested is:
* (VALUE < $from) || (VALUE > $to)
* @param mixed $from The lowest value of the excluded range
* @param mixed $to The higherst value of the excluded range
* @param boolean $include Should we include the boundaries in the search?
* @return string The SQL where clause for this search
abstract public function outside($from, $to, $include =
false);
* Perform an interval search (usually: a date interval check)
* @param string $from The value to search
* @param string|array|object $interval The interval
* @return string The SQL where clause for this search
abstract public function interval($from, $interval);
* Return the SQL where clause for a search
* @param mixed $value The value to search for
* @param string $operator The operator to use
* @return string The SQL where clause for this search
public function search($value, $operator =
'=')
return '(' .
$this->getFieldName() .
' ' .
$operator .
' ' .
$this->_db->quote($value) .
')';
* Get the field name with the given table alias
* @return string The field name
$name =
$this->_db->qn($this->name);
* Creates a field Object based on the field column type
* @param object $field The field informations
* @param array $config The field configuration (like the db object to use)
* @return FOFModelField The Field object
public static function getField($field, $config =
array())
$classType =
self::getFieldType($type);
$className =
'FOFModelField' .
$classType;
if (isset
($config['dbo']))
if (isset
($config['table_alias']))
$table_alias =
$config['table_alias'];
$field =
new $className($db, $field, $table_alias);
* Get the classname based on the field Type
* @param string $type The type of the field
* @return string the class suffix
case 'character varying':
case 'timestamp without time zone':
case 'timestamp with time zone':
Documentation generated on Tue, 19 Nov 2013 15:02:59 +0100 by phpDocumentor 1.4.3