FOF30\Model\DataModel\Filter\Text::exact PHP Метод

exact() публичный Метод

Perform an exact match (match string)
public exact ( mixed $value ) : string
$value mixed The value to compare to
Результат string The SQL where clause for this search
    public function exact($value)
    {
        if ($this->isEmpty($value)) {
            return '';
        }
        if (is_array($value) || is_object($value)) {
            settype($value, 'array');
            $db = $this->db;
            $value = array_map(array($db, 'quote'), $value);
            return '(' . $this->getFieldName() . ' IN (' . implode(',', $value) . '))';
        }
        return '(' . $this->getFieldName() . ' LIKE ' . $this->db->quote($value) . ')';
    }

Usage Example

Пример #1
0
 /**
  * @group           TextFilter
  * @group           TextFilterExact
  * @covers          FOF30\Model\DataModel\Filter\Text::exact
  * @dataProvider    TextDataprovider::getTestExact
  */
 public function testExact($test, $check)
 {
     $msg = 'Text::exact %s - Case: ' . $check['case'];
     $filter = new Text(\JFactory::getDbo(), (object) array('name' => 'test', 'type' => 'varchar(10)'));
     $result = $filter->exact($test['value']);
     $this->assertEquals($check['result'], $result, sprintf($msg, 'Failed to build the correct SQL query'));
 }