Contao\Database::getParentRecords PHP Méthode

getParentRecords() public méthode

Return the IDs of all parent records of a particular record
public getParentRecords ( integer $intId, string $strTable ) : array
$intId integer The ID of the record
$strTable string The table name
Résultat array An array of parent record IDs
    public function getParentRecords($intId, $strTable)
    {
        $arrReturn = array();
        // Currently supports a nesting-level of 10
        $objPages = $this->prepare("SELECT id, @pid:=pid FROM {$strTable} WHERE id=?" . str_repeat(" UNION SELECT id, @pid:=pid FROM {$strTable} WHERE id=@pid", 9))->execute($intId);
        while ($objPages->next()) {
            $arrReturn[] = $objPages->id;
        }
        return $arrReturn;
    }