PHP Wrappers - DataSourceResult - function where()

5 posts, 2 answers
  1. Paweł Kasztelan
    Paweł Kasztelan avatar
    17 posts
    Member since:
    Aug 2012

    Posted 09 May 2013 Link to this post

    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.


  2. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 13 May 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Paweł Kasztelan
    Paweł Kasztelan avatar
    17 posts
    Member since:
    Aug 2012

    Posted 21 May 2013 Link to this post

    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.



  5. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 22 May 2013 Link to this post

    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!
  6. Paweł Kasztelan
    Paweł Kasztelan avatar
    17 posts
    Member since:
    Aug 2012

    Posted 22 May 2013 Link to this post

    I just checked patch, act truly elegantly!
Back to Top
Kendo UI is VS 2017 Ready