Ejemplo n.º 1
0
void GraphNode :: printPublications(){
	printf("pubsList: \n");
	
	for (int p =0; p< pubs.size(); p++){
		Article * tmp = pubs.at(p);
		//printf(" %i 'th id is:  \n", p);
		printf(" article %i: %s, %s \n", p+1, tmp->getId().c_str(), tmp->getTitle().c_str());
	}
	
}
Ejemplo n.º 2
0
/*
 * AJJOUTEZ UN ARTICLE
 *
*/
int articledao::addArticle(Article &article)
{
    QSqlDatabase db = QSqlDatabase::database();
    if(db.open()){
        QSqlQuery q;

        q.prepare(QLatin1String("insert into Article(name,description,page,magazine) values(?,?,?,?)"));
        q.addBindValue(article.getTitle());
        q.addBindValue(article.getDescription());
        q.addBindValue(article.getPage());
        q.addBindValue(article.getmagID());

        q.exec();

        db.close();
        return q.lastInsertId().toInt();
    }
    //fail to connect
    return -1;
}
Ejemplo n.º 3
0
/*
 * UPDATE UN ARTICLE
 *
*/
int articledao::updateArticle(Article &article)
{
    QSqlDatabase db = QSqlDatabase::database();
    if(db.open()){
        QSqlQuery q;

        q.prepare(QLatin1String("UPDATE Article SET name = ?, description = ?, page = ?,magazine = ? WHERE ID = ?"));
        q.addBindValue(article.getTitle());
        q.addBindValue(article.getDescription());
        q.addBindValue(article.getPage());
        q.addBindValue(article.getmagID());
        q.addBindValue(article.getID());

        q.exec();

        db.close();
        return article.getID();
    }
    //fail to connect
    return -1;
}