A function to call a stored procedure with an arbitrary number of IN parameters and one OUT parameter, for instance returning affected row count. The return value of yhe function is this value.
<?php
function call_sp( \mysqli $db, string $sp_name, ...$params ): int
{
  $sql = "CALL $sp_name( ";
  $sql .= implode( ", ", array_fill( 0, count( $params ), "?" ) );
  $sql .= ", @__affected );";
  $result   = $db->execute_query( $sql, $params );
  $result   = $db->query( "select @__affected;" );
  $affected = (int) $result->fetch_column( 0 );
  return $affected;
}