예제 #1
0
 /**
  * Add record
  *
  * @param array $values
  * @return int
  */
 public function add(array $values)
 {
     list($sql, $values) = $this->compiler->insert($this->name, $values);
     // prepare statement & execute
     if ($statement = $this->pdo->prepare($sql) and $result = $statement->execute($values)) {
         return $this->pdo->lastInsertId();
     }
     // error
     $error = $this->pdo->errorInfo();
     throw new \PDOException('[' . $error[0] . '] ' . $error[2], $error[0]);
 }