'PHP PDO Sort Function error codes: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256'

i am trying the sort operation in function but i am getting the error given below.

I'm leaving the function codes below

error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256'

operation.php

 $categorySort = (!empty(htmlspecialchars($_POST['categorySort']))) ? htmlspecialchars($_POST['categorySort']) : 1;
 $query = "select * from ortoped6_dernek.categories where categorySort=:categorySort";
 $params = [['categorySort', $categorySort, PDO::PARAM_INT]];
 echo $sort = sortControl($query, $params, $categorySort);

funtion.php

/**
 * @param string $query
 * @param array $params
 * @param int $sort
 * @param int $parent
 * @return int
 */
function sortControl(string $query, array $params, int $sort, int $parent = 0): int
{

    global $db;

    global $result;

    $queryOrder = $db->prepare("$query");
    foreach ($params as $param) {
        $querySort->bindParam($param[0], $param[1], $param[2]);
    }

    $querySort->execute();

   $control = $querySort->rowCount();

    if ($control > 0) {
        $sorts = $sort+ 1;
        sortControl($query, $params, $sorts);

    } else {
        $result = $sort;
    }

    return $result;
}

Does someone know the answer?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source