Guest User

Untitled

a guest
Dec 5th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool addDirectors(const Movie &theMovie)
  2. {
  3.     QStringListIterator it(theMovie.directors_);
  4.  
  5.     while(it.hasNext())
  6.     {
  7.         QSqlQuery query("SELECT NAME FROM DIRECTOR WHERE NAME = :name;");
  8.         query.bindValue(":name", it.);
  9.  
  10.         if(query.isNull())
  11.         {
  12.             query("INSERT INTO DIRECTOR(NAME) VALUES (:name);");
  13.             query.bindValue(":name", *it);
  14.         }
  15.  
  16.         query("INSERT INTO DIRECT(ID, NAME, USERNAME) VALUES (:id, :name, :username);");
  17.         query.bindValue(":id", theMovie.id_);
  18.         query.bindValue(":name", *it);
  19.         query.bindValue(":username", theMovie.username_);
  20.  
  21.         query.clear();
  22.     }
  23. }
Add Comment
Please, Sign In to add comment