Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Victor Oviedo
    queryObject with empty resultAnswered
    Topic posted July 29, 2019 by Victor Oviedo, last edited July 29, 2019, tagged Connect PHP 
    26 Views, 4 Comments
    Title:
    queryObject with empty result
    Summary:
    queryObject with empty result
    Content:

    I have developed a php script where I use a query to bring specific items of a Custom Object (Resource), when I use the following code:

    $queryResult = RNCPHP\ROQL::queryObject("select R from CO.Resource R where ID=3021 or ID=3019 or ID=3018 or ID=3015")->next(); var_dump($queryResult);

    When I execute this code this is the var_dump result:

    object(RightNow\Connect\v1_3\ROQLResult)#4 (0) { }

    Why is this happening?, it is something I should add/change/remove?

    Version:
    1_3

    Best Comment

    Lakshay Bhalla

    Hi Victor,

    When you var_dump Object it returns only what you have written "object(RightNow\Connect\v1_3\ROQLResult)#4 (0) { }".

    You need to do it like this:

    While($finalResult = $queryResult->next()){

    var_dump($finalResult->any_column_name); // or print_r($finalResult->any_column_name);

    }

    But When you do var_dump($finalResult) it does not show any values instead column names with Null Values returned.

    Comment

     

    • Lakshay Bhalla

      Hi Victor,

      When you var_dump Object it returns only what you have written "object(RightNow\Connect\v1_3\ROQLResult)#4 (0) { }".

      You need to do it like this:

      While($finalResult = $queryResult->next()){

      var_dump($finalResult->any_column_name); // or print_r($finalResult->any_column_name);

      }

      But When you do var_dump($finalResult) it does not show any values instead column names with Null Values returned.

      • Victor Oviedo

        Hi Lakshay,

        Thanks for the answer, and now I see the value. But the point now is that the query only brings one result. It should be 4, but inside the while only show one result (the one with ID= 3015). The other ids exist. I executed the script using a single ID in the query, and it works. But curiosity still bites to me. Why is not working if I make the query with multiple ID separated by "or" in PHP?

        • Lakshay Bhalla

          Hi victor,

          I ran similar query to yours and it returned multiple rows for each ID i had written using "OR".

          Try running the for each ID individually and then try running using 2 IDs at a time then increase IDs in query and see if it returns results.

          Thanks

          -Lakshay

          • Victor Oviedo

            Hi Lakshay,

            I tried what you said and I found the problem, I was using same variable for saving another queryObject and the variable was overwritten frown.

            Thanks a lot for the answers!.