Ejemplo n.º 1
0
bool PingFlow::erase(DBManager &dbm)
{
    char sql[500];
    sprintf(sql, "DELETE FROM %s WHERE `pingId`='%d';", this->get_table_name().c_str(), this->get_ping_id());
    dbm.sql_execute(sql);
    return true;
}
Ejemplo n.º 2
0
bool PingFlow::update(DBManager &dbm)
{
    char sql[500];
    sprintf(sql, "UPDATE %s SET `sendPackage`='%d', `receivePackage`='%d', `lostPackage`='%d', `minTime`='%d', `maxTime`='%d', `averageTime`='%d', `errorMessage`='%s', `pingTime`='FROM_UNIXTIME(%ld)'WHERE `pingId`='%d';",\
            this->get_table_name().c_str(),  this->send_package, this->receive_package, this->lost_package, this->min_time, this->max_time, this->average_time, this->error_message, this->ping_time, this->ping_id);
    dbm.sql_execute(sql);
    return true;
}
Ejemplo n.º 3
0
bool PingFlow::create(DBManager &dbm)
{
    char sql[500];
    sprintf(sql, "INSERT INTO %s (`sendPackage`, `receivePackage`, `lostPackage`, `minTime`, `maxTime`, `averageTime`, `errorMessage`, 'pingTime') VALUES \
                                    ('%d', '%d', '%d', '%d', '%d', '%d', '%s', 'FROM_UNIXTIME(%ld)')", \
            this->get_table_name().c_str(),  this->send_package, this->receive_package, this->lost_package, this->min_time, this->max_time, this->average_time, this->error_message, this->ping_time);
    dbm.sql_execute(sql);
    return true;
}
Ejemplo n.º 4
0
std::vector<ObjectFoundation*> PingFlow::find_all(DBManager &dbm)
{
    char sql[500];
    sprintf(sql, "SELECT * FROM %s;", this->get_table_name().c_str());
    std::cout << sql << std::endl;
    dbm.sql_execute(sql);
    m_sql_list sql_list = dbm.get_sql_res();
    m_sql_object sql_object;
    std::vector<ObjectFoundation*> pfl;
    if (sql_list.size()==0) {
        std::cout << "Object not found!" << std::endl;
    } else {
        m_sql_list::iterator iter = sql_list.begin();
        for (; iter != sql_list.end(); iter++) {
            pfl.push_back(this->to_object(*iter));
        }
    }
    return pfl;
}