Check if ID exist or not
Function modelExist should check if model exists and return boolean. Your function does something completely different. It only needs that check for its job.

public function modelExists(int $modelId): bool;


To check existence of a row, you don't need all its columns. Select just 1 (literally) and check if you have received a row from the query or not.

SELECT 1 FROM models_web_tbl WHERE model_id = ?


Create another function for the insert

public function insertModel(int $modelId, string $modelWeb): void


Maybe you wanted to combine it into another function.

public function tryInsert(int $modelId, string $modelWeb): bool
{
  if ($this-&gt;modelExists($modelId)) {
    return false;
  }
  $this-&gt;insert($modelId, $modelWeb);
  return true;
}


Don't connect to database again for every query

class test
{
  private PDO $connection;
  function __construct(PDO $connection) {
    $this-&gt;connection = $connection;
  }
  function modelExists(int $modelId): bool
  {
    // ...
    $this-&gt;connection-&gt;prepare($sql);
    // ...
  }

  function insert(int $modelId, $modelWeb): void
  {    
    // ...
    $this-&gt;connection-&gt;prepare($sql);
    // ...
  }
}


$connection = connect();
$test = new test($connection);
  // I don't know why it was important to assign 'twitter' to a variable first :)
if (!$test-&gt;tryInsert($model_id, 'twitter')) {
  // echo definitely dont belong into exists-check function
  echo "found";
}