/** * Creates a searchcondition for the field, * was once part of searchCondition, however, * searchcondition() also immediately adds the search condition. * * @param Query $query The query object where the search condition should be placed on * @param string $table The name of the table in which this attribute * is stored * @param mixed $value The value the user has entered in the searchbox * @param string $searchmode The searchmode to use. This can be any one * of the supported modes, as returned by this * attribute's getSearchModes() method. * @param string $fieldname * * @return string The searchcondition to use. */ public function getSearchCondition(Query $query, $table, $value, $searchmode, $fieldname = '') { // When we get $value as a substring, we autocomplete the time // So 9 becomes 09:00:00 and 11:15 becomes 11:15:00 if (!is_array($value)) { $retval = array('hours' => substr($value, 0, 2), 'minutes' => substr($value, 3, 2), 'seconds' => substr($value, 6, 2)); if (!$retval['seconds']) { $retval['seconds'] = '00'; } if (!$retval['minutes']) { $retval['minutes'] = '00'; } if (strlen($retval['hours']) == 1) { $retval['hours'] = '0' . $retval['hours']; } if (strlen($retval['minutes']) == 1) { $retval['minutes'] = '0' . $retval['minutes']; } if (strlen($retval['seconds']) == 1) { $retval['seconds'] = '0' . $retval['seconds']; } $value = implode(':', $retval); } return parent::getSearchCondition($query, $table, $value, $searchmode); }
public function getSearchCondition(Query $query, $table, $value, $searchmode, $fieldname = '') { $value = $this->processSearchValue($value, $searchmode); if ($searchmode != 'between') { if ($value['from'] != '') { $value = $value['from']; } elseif ($value['to'] != '') { $value = $value['to']; } else { return ''; } return parent::getSearchCondition($query, $table, $value, $searchmode); } $fieldname = $table . '.' . $this->fieldName(); return $this->getBetweenCondition($query, $fieldname, $value); }