This is a migrated thread and some comments may be shown as answers.

PHP Wrappers - DataSourceResult - function where()

4 Answers 176 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Paweł Kasztelan
Top achievements
Rank 2
Paweł Kasztelan asked on 09 May 2013, 06:50 AM
Welcome. I tested PHP wrappers for KendoUI. I found a problem / bug.

If you use AutoComplete control to retrieve data about the elements, such as a telephone, social security number, tax ID, ID, ID card number, barcode, etc are DataSourceResult-> Read () does not return any result.
The problem is the WHERE clause.

private function where($properties, $filter, $all) {
    if (isset($filter->filters)) {
        $logic = ' AND ';
 
        if ($filter->logic == 'or') {
            $logic = ' OR ';
        }
 
        $filters = $filter->filters;
 
        $where = array();
 
        for ($index = 0; $index < count($filters); $index++) {
            $where[] = $this->where($properties, $filters[$index], $all);
        }
 
        $where = implode($logic, $where);
 
        return "($where)";
    }
 
    $field = $filter->field;
 
    if (in_array($field, $properties)) {
        $index = array_search($filter, $all);
 
        $value = ":filter$index";
 
        if ($this->isDate($filter->value)) {
            $field = "date($field)";
            $value = "date($value)";
        }
 
        if ($this->isString($filter->value)) {
            $operator = $this->stringOperators[$filter->operator];
        } else {
            $operator = $this->operators[$filter->operator];
        }
 
        return "$field $operator $value";
    }
}
Should pay attention to excerpt:
if ($this->isString($filter->value)) {
                $operator = $this->stringOperators[$filter->operator];
            } else {
                $operator = $this->operators[$filter->operator];
            }
At the time of transmission by the AutoComplete type information '90080800418 '(Social Security) is used in an incorrect set of operators.

private $stringOperators = array(
        'eq' => 'LIKE',
        'neq' => 'NOT LIKE',
        'doesnotcontain' => 'NOT LIKE',
        'contains' => 'LIKE',
        'startswith' => 'LIKE',
        'endswith' => 'LIKE'
    );
private
$operators = array(
        'eq' => '=',
        'gt' => '>',
        'gte' => '>=',
        'lt' => '<',
        'lte' => '<=',
        'neq' => '!='
    );
The indicator provides information and an operator that has been used is startswith is not in the $operators.
{"filter":{"logic":"and","filters":[{"value":"90080800418","operator":"startswith","field":"kh_Imie","ignoreCase":true}]}}
I leave the matter to think about. It was enough to add operators to the $operators, but it is possible that you will want to develop something else.


4 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 13 May 2013, 02:40 PM
Hello Marek,

 Thank you for reporting this problem! We will fix it by adding an additional check for the filter operator so it handles this case. The fix will be part of the upcoming service pack.

All the best,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Paweł Kasztelan
Top achievements
Rank 2
answered on 21 May 2013, 12:44 PM
I noticed another problem with Social Security numbers. If I type only member 90080800 (full number: 90080800419) (after which it should be detailing results) function recognizes the character string as a date.
if ($this->isDate($filter->value)) {
            $field = "date($field)";
            $value = "date($value)";
        }
Inability to indicate whether the string is sent to be treated as a string or as a date.
The problem will also be performed with barcodes and other identification numbers.



0
Accepted
Atanas Korchev
Telerik team
answered on 22 May 2013, 12:41 PM
Hi Marek,

 Thank you for reporting this issue. We decided to add support for specifying the property type. For example:

$result->read('Orders', array('ShipName' => array("type" =>"string"), "Freight"), $request);

The supported types are: "string", "date" and "number". If the type isn't specified the DataSourceResult will try to guess it based on the filter value (as before).

Find attached the updated PHP file.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Paweł Kasztelan
Top achievements
Rank 2
answered on 22 May 2013, 01:30 PM
I just checked patch, act truly elegantly!
Tags
AutoComplete
Asked by
Paweł Kasztelan
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Paweł Kasztelan
Top achievements
Rank 2
Share this question
or