Example #1
0
 public static function getAggregate($className, $function, ARFieldHandleInterface $handle, ARSelectFilter $filter, $loadReferencedRecords = null)
 {
     $query = self::createSelectQuery($className, $loadReferencedRecords);
     $query->getFilter()->merge($filter);
     $query->removeFieldList();
     $query->addField($function . '(' . $handle->toString() . ')', null, 'result');
     $res = self::getDataByQuery($query);
     return $res[0]['result'];
 }
Example #2
0
 /**
  *	Creates an ARExpressionHandle for performing searches over language fields (finding a value in particular language)
  *	Parses the PHP serialized string value. Performance is usually not a problem, because the rows should first be filtered by a simple LIKE condition
  *
  *	@return ARExpressionHandle
  */
 public static function getLangSearchHandle(ARFieldHandleInterface $field, $language)
 {
     $substr = "\n\t\t\tSUBSTRING(\n\t\t\t\tSUBSTRING_INDEX(" . $field->toString() . ",'\"" . $language . "\";s:',-1),\n\t\t\t\tCEIL(LOG10(\n\t\t\t\t\tSUBSTRING_INDEX(\n\t\t\t\t\t\tSUBSTRING_INDEX(" . $field->toString() . ",'\"" . $language . "\";s:',-1),\n\t\t\t\t\t\t':',\n\t\t\t\t\t\t1) + 1\n\t\t\t\t\t)) + 3,\n\t\t\t\tSUBSTRING_INDEX(\n\t\t\t\t\tSUBSTRING_INDEX(" . $field->toString() . ",'\"" . $language . "\";s:',-1),\n\t\t\t\t\t':',\n\t\t\t\t\t1)\n\t\t\t\t)";
     // UTF-8 strings
     // PHP serialized strings include the field length in bytes, however the MySQL string functions are UTF-8 aware
     // and the resulting strings are too long when they include multi-byte characters, so they need to be shortened accordingly
     $expression = "SUBSTRING(" . $substr . ", 1, CHAR_LENGTH(" . $substr . ") - (LENGTH(" . $substr . ") - CHAR_LENGTH(" . $substr . ")))";
     return new ARExpressionHandle($expression);
 }
Example #3
0
 public function isSortedBy(ARFieldHandleInterface $fieldHandle, $orderType = self::ORDER_ASC)
 {
     return !empty($this->fieldListForOrder[$fieldHandle->toString()]);
 }