Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. void RequetteBDD::add(Files::Fichier file)
  2. {
  3.  
  4. string query = "INSERT INTO files(titre,url,type,txt,lastcrawl) VALUES (?,?,?,?,?)";
  5.  
  6. sql::PreparedStatement *prep_stmt;
  7.  
  8. prep_stmt = con->prepareStatement(query);
  9.  
  10. prep_stmt->setString(1,file.getNom()); //title
  11. prep_stmt->setString(2,file.getURL().getUri()); //url
  12. prep_stmt->setInt(3,file.getTypeInt()); //type
  13.  
  14. //i also try :
  15. istringstream stream(file.getTextFull());
  16. prep_stmt->setBlob(4,&stream);
  17. //but the saved length was exactly the same.
  18.  
  19. prep_stmt->setString(4,file.getTextFull()); //here is the probleme
  20.  
  21. prep_stmt->setInt(5,time(NULL)); //timstamp
  22.  
  23. prep_stmt->execute();
  24. delete prep_stmt;
  25.  
  26. }
  27.  
  28. CREATE TABLE IF NOT EXISTS `files` (
  29. `id` int(11) NOT NULL AUTO_INCREMENT ,
  30. `titre` varchar(256) COLLATE utf8_unicode_ci NOT NULL,
  31. `url` varchar(512) COLLATE utf8_unicode_ci NOT NULL,
  32. `type` int(1) NOT NULL DEFAULT '0' COMMENT ,
  33. `txt` longtext COLLATE utf8_unicode_ci NOT NULL,
  34. `lastcrawl` int(11) NOT NULL,
  35. PRIMARY KEY (`id`)
  36. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement