Example #1
0
Project::Project(const Project& orig): BaseRecord(orig.connector, orig.table)
{
    this->Name(orig.Name());
    this->Description(orig.Description());
    this->SetTeam(orig.GetTeam());
    this->TimmingPlan(orig.TimmingPlan());
    this->SetStatus(orig.GetStatus());
    this->CreatedAt(orig.CreatedAt());
    this->ExpiredAt(orig.ExpiredAt());
    this->Deadline(orig.Deadline());
    this->Priority(orig.Priority());
}
Example #2
0
vector<BaseRecord *> Project::RetrieveTableRecords(string where, string limit) const
{
    vector<BaseRecord *> projects;
    BaseRecord* baseRecord;
    MYSQL_RES* res;
    MYSQL_ROW row;
    Project* project;
    string sql;
    
    sql = "SELECT `id`, `name`, `description`, `team`, `timming_plan`, `status`, `created_at`, `expired_at`, `deadline`, `priority` FROM `" 
            + this->table + "` " + where + " " + limit;
    
    try {
        res = this->connector->Query(sql, SELECT);
    }
    catch(MySQLRecordNotFound* rnf) {
        std::cout << rnf->what() << std::endl;
        exit(ERROR_MYSQL_QUERY);
    }
    
    while(row = mysql_fetch_row(res)) {
        project = new Project(this->connector);
        project->id = atoi(row[0]);
        project->Name(row[1]);
        project->Description(row[2]);
        project->SetTeam(new Team(this->connector, atoi(row[3])));
        project->TimmingPlan(atof(row[4]));
        project->SetStatus(new Status(this->connector, atoi(row[5])));
        project->CreatedAt(new DateTime(atoi(row[6])));
        project->ExpiredAt(new DateTime(atoi(row[7])));
        project->Deadline(new DateTime(atoi(row[8])));
        project->Priority(atoi(row[9]));
        baseRecord = project;
        projects.push_back(baseRecord);
    }
    
    return projects;
}