Skip Navigation
Expand
  • Advanced SearchOpens new dialog
    Enter plus (+) or minus (-) signs in search terms to make a word required or excluded
    Search Tips
    Filter by product
    Filter by category
How to work with CPHP threads array
Answer ID 10544   |   Last Review Date 02/06/2025

How is the list of incident threads retrieved from the database when using Connect PHP API?

Environment

All Oracle B2C Service versions
Resolution
When updates are added to a service request, they are stored in the database and assigned a thread ID consecutively i.e. 1 for the first update, 2 for the second update etc.
However, when they are retrieved in an array using the Connect PHP API, the last entry in the database will always occupy the first position in the array.

For instance, if there are five threads for a specific service request, in order to retrieve the most recent thread ID (5), one must use the code below:
 

try{
    $Incident = RNCPHP\Incident::fetch(235808);
    $recent_thread = $Incident->Threads[0]->ID;
    echo $recent_thread;    
}
    }catch(\Exception $e){
        echo $e."<br>";
    }
 
Following the same logic, in order to retrieve the very first thread on the service request, one must use the code below:

 

try{
    $Incident = RNCPHP\Incident::fetch(235808);
    $first_thread = $Incident->Threads[4]->ID;
    echo $first_thread;    
}    }catch(\Exception $e){
        echo $e."<br>";
    }
 
More details on how to use the Connect PHP API with threads can be found by accessing the documentation we have available for Thread Entry.