Executing non-SELECT queries

While it is possible to use the query() method with non-SELECT queries, it is not an ideal. Instead, it is better to use the exec()open in new window method for it will return the number of rows affected.

<?php
  require_once "db.php";
  $sql = "INSERT INTO movies (`movie_title`, `director`, `year`, `genre_id`) 
          VALUES ('Pulp Fiction', 'Quentin Tarantino', 1994, 5)";
  $result = $db->exec($sql);
  echo $result // 1