void DbManager::createTables()
{
    execQuery("CREATE TABLE Persons ( "
              "pID INTEGER PRIMARY KEY AUTOINCREMENT, " //we don't have to worry about ID with autoincrement
              "name VARCHAR[40], "
              "gender VARCHAR[7], " //this might be changed to char
              "dob DATE, "
              "dod DATE, "
              "UNIQUE (name) )");

    execQuery("CREATE TABLE Computers ( "
              "cID INTEGER PRIMARY KEY AUTOINCREMENT, "
              "name VARCHAR[40], "
              "year INT, "
              "type VARCHAR[20], "
              "built BOOLEAN, "
              "UNIQUE (name) )");

    execQuery("CREATE TABLE ComputersXPersons ( "
              "pID INT, "
              "cID INT, "
              "FOREIGN KEY (pID) REFERENCES Persons(pID), "
              "FOREIGN KEY (cID) REFERENCES Computers(cID), "
              "PRIMARY KEY(pID, cID))");
}
	RESULT YandexNarodHTTPConnector::getFiles(QString& response)
	{
		QString header = "Cookie: ";
        for(int i=0; i<m_cookies.count(); i++)
		{
            header += m_cookies.at(i) + "; ";
		}
		QString post = "";
		int err = execQuery("http://narod.yandex.ru/disk/all/page1/?sort=cdate%20desc", header, post, &response);
		QString tmp(response);
		int page = 1;
		int cpos = 0;
		while(err == 200 && cpos >= 0)
		{
			QRegExp rxnp("<a\\sid=\"next_page\"\\shref=\"([^\"]+)\"");
			cpos = rxnp.indexIn(tmp);
			if(cpos>0 && rxnp.capturedTexts()[1].length())
			{
				tmp = "";
				QString url = "http://narod.yandex.ru/disk/all/page" + QString::number(++page) + "/?sort=cdate%20desc";
				err = execQuery(url, header, post, &tmp);
				response.append(tmp);
			}
		}
		return (err == 200) ? eNO_ERROR : eERROR_GENERAL;
	}
示例#3
0
int Library::addCategoriesToDb(const QList<FilePath>& dirs, const QString& tablename,
                               const QString& id_rowname) throw (Exception)
{
    int count = 0;
    foreach (const FilePath& filepath, dirs)
    {
        ElementType element(filepath);

        QSqlQuery query = prepareQuery(
            "INSERT INTO " % tablename % " "
            "(filepath, uuid, version, parent_uuid) VALUES "
            "(:filepath, :uuid, :version, :parent_uuid)");
        query.bindValue(":filepath",    filepath.toRelative(mLibPath));
        query.bindValue(":uuid",        element.getUuid().toStr());
        query.bindValue(":version",     element.getVersion().toStr());
        query.bindValue(":parent_uuid", element.getParentUuid().isNull() ? QVariant(QVariant::String) : element.getParentUuid().toStr());
        int id = execQuery(query, true);

        foreach (const QString& locale, element.getAllAvailableLocales())
        {
            QSqlQuery query = prepareQuery(
                "INSERT INTO " % tablename % "_tr "
                "(" % id_rowname % ", locale, name, description, keywords) VALUES "
                "(:element_id, :locale, :name, :description, :keywords)");
            query.bindValue(":element_id",  id);
            query.bindValue(":locale",      locale);
            query.bindValue(":name",        element.getNames().value(locale));
            query.bindValue(":description", element.getDescriptions().value(locale));
            query.bindValue(":keywords",    element.getKeywords().value(locale));
            execQuery(query, false);
        }
        count++;
    }
示例#4
0
void DialogShoot::on_mpButtonShoot_clicked()
{
    execQuery(QString("UPDATE objects SET status = 'S' WHERE id = %1")
              .arg(mIdObject));
    execQuery(QString("INSERT INTO shoot (id, comment) VALUES(%1, '%2')")
              .arg(mIdObject)
              .arg(ui->mpEditor->toPlainText()));
    accept();
}
示例#5
0
文件: model.cpp 项目: Aspenka/ORM
/*==============================================================================
 Метод сохраняет модель в БД
==============================================================================*/
bool Model::save()
{
    if(isExists())
    {
        QString res = generateUpdate();
        return execQuery(res);
    }
    QString res = generateInsert();
    setExists(true);
    return execQuery(res);
}
示例#6
0
/// Return a list of all the objects/rows (by id) that contain 'value' in a certain column
/// ex: AMDatabase::db()->scansContaining("name", "Carbon60") could return Scans with names Carbon60_alpha and bCarbon60_gamma
QList<int> AMDatabase::objectsContaining(const QString& tableName, const QString& colName, const QVariant& value)
{

	QList<int> rl;

	/// \todo sanitize more than this...
	if(tableName.isEmpty() || colName.isEmpty()) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -10, "Could not search the database. (Missing the table name or column name.)"));
		return rl;
	}


	QSqlQuery q( qdb() );

	q.prepare(QString("SELECT id FROM %1 WHERE %2 LIKE ('%' || :val || '%')").arg(tableName).arg(colName));

	q.bindValue(":val", value);
	execQuery(q);

	while(q.next()) {
		rl << q.value(0).toInt();
	}
	q.finish();


	return rl;
}
示例#7
0
/// Return a list of all the objects/rows (by id) that match 'value' in a certain column.
/// ex: AMDatabase::db()->objectsMatching("name", "Carbon60"), or AMDatabase::db()->objectsMatching("dateTime", QDateTime::currentDateTime())
QList<int> AMDatabase::objectsMatching(const QString& tableName, const QString& colName, const QVariant& value)
{
	// return value: list of id's that match
	QList<int> rl;

	/// \todo sanitize more than this...
	if(tableName.isEmpty() || colName.isEmpty()) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -10, "Could not search the database. (Missing the table name or column name.)"));
		return rl;
	}

	QSqlQuery q( qdb() );

	// For date/times, we want a resolution of one minute to count as a match
	if(value.type() == QVariant::DateTime) {
		q.prepare(QString("SELECT id FROM %1 WHERE %2 BETWEEN datetime(?, '-1 minute') AND datetime(?, '+1 minute')").arg(tableName).arg(colName));
		q.bindValue(0, value);
		q.bindValue(1, value);
	}
	else {
		q.prepare(QString("SELECT id FROM %1 WHERE %2 = ?").arg(tableName).arg(colName));
		q.bindValue(0, value);
	}
	execQuery(q);

	while(q.next()) {
		rl << q.value(0).toInt();
	}
	q.finish();

	return rl;
}
示例#8
0
/// returns a list of all the objecst/rows (by id) that match a given condition. \c whereClause is a string suitable for appending after an SQL "WHERE" statement.
QList<int> AMDatabase::objectsWhere(const QString& tableName, const QString& whereClause)
{
	QList<int> rl;

	/// \todo sanitize more than this...
	if(tableName.isEmpty()) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -10, "Could not search the database. (Missing the table name.)"));
		return rl;
	}

	QSqlQuery q( qdb() );

	QString query = "SELECT id FROM " % tableName;
	if(!whereClause.isEmpty())
		query.append(" WHERE ").append(whereClause);

	q.prepare(query);
	execQuery(q);

	while(q.next()) {
		rl << q.value(0).toInt();
	}
	q.finish();


	return rl;
}
示例#9
0
QVariant AMDatabase::retrieve(int id, const QString& table, const QString& colName)
{
	/// \todo sanitize more than this...
	if(table.isEmpty()) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -10, "Could not search the database. (Missing the table name.)"));
		return false;
	}

	// create a query on our database connection:
	QSqlQuery q( qdb() );


	/// Prepare the query. \todo: sanitize column names and table name. (Can't use binding because it's not an expression here)
	q.prepare(QString("SELECT %1 FROM %2 WHERE id = ?").arg(colName).arg(table));
	q.bindValue(0,id);

	// run query. Did it succeed?
	if(!execQuery(q)) {
		q.finish();	// make sure that sqlite lock is released before emitting signals
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -4, QString("database retrieve failed. Could not execute query (%1). The SQL reply was: %2").arg(q.executedQuery()).arg(q.lastError().text())));
		return false;
	}
	// If we found a record at this id:
	if(q.first()) {
		return q.value(0);
	}
	// else: didn't find this id.  That's normal if it's not there, just return null QVariant.
	else {
		return QVariant();
	}

}
示例#10
0
/*! table is the database table name
 colName is the name of the column you wish to get all the values for
 values is a list of pointers to QVariants that will be modified with the retrived values.
 (Note that the const and & arguments are designed to prevent memory copies, so this should be fast.)
 Return value: returns the list of values
*/
QVariantList AMDatabase::retrieve(const QString& table, const QString& colName)
{
	QVariantList values;	// return value

	/// \todo sanitize more than this...
	if(table.isEmpty()) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, AMDATABASE_MISSING_TABLE_NAME_IN_RETRIEVE, "Could not search the database. (Missing the table name.)"));
		return values;
	}

	// create a query on our database connection:
	QSqlQuery q( qdb() );

	// Prepare the query.
	q.prepare(QString("SELECT %1 FROM %2").arg(colName).arg(table));

	// run query. Did it succeed?
	if(!execQuery(q)) {
		q.finish();	// make sure that sqlite lock is released before emitting signals
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, AMDATABASE_RETRIEVE_QUERY_FAILED, QString("database retrieve failed. Could not execute query (%1). The SQL reply was: %2").arg(q.executedQuery()).arg(q.lastError().text())));
		return values;
	}

	while(q.next())
		values << q.value(0);

	q.finish();	// make sure that sqlite lock is released before emitting signals
	// otherwise: didn't find this column.  That's normal if it's not there, just return empty list
	return values;
}
示例#11
0
/*! id is the object's row in the database.
 table is the database table name
 colNames is a list of the column names that the values will be retrieved from
 values is a list of pointers to QVariants that will be modified with the retrived values.
 (Note that the const and & arguments are designed to prevent memory copies, so this should be fast.)
 Return value: returns true on success.
*/
QVariantList AMDatabase::retrieve(int id, const QString& table, const QStringList& colNames)
{
	QVariantList values;	// return value

	/// \todo sanitize more than this...
	if(table.isEmpty()) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -10, "Could not search the database. (Missing the table name.)"));
		return values;
	}

	// create a query on our database connection:
	QSqlQuery q( qdb() );

	// Create the list of columns:
	QString cols = colNames.join(", ");	// this will become something like "name, number, sampleName, comments, startTime"
	// Prepare the query. Todo: sanitize column names and table name. (Can't use binding because it's not an expression here)
	q.prepare(QString("SELECT %1 FROM %2 WHERE id = ?").arg(cols).arg(table));
	q.bindValue(0,id);

	// run query. Did it succeed?
	if(!execQuery(q)) {
		q.finish();	// make sure that sqlite lock is released before emitting signals
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -4, QString("database retrieve failed. Could not execute query (%1). The SQL reply was: %2").arg(q.executedQuery()).arg(q.lastError().text())));
		return values;
	}
	// If we found a record at this id:
	if(q.first()) {
		// copy columns to return values:
		for(int i=0; i<colNames.count(); i++)
			values << q.value(i);
	}
	q.finish();	// make sure that sqlite lock is released before emitting signals
	// otherwise: didn't find this id.  That's normal if it's not there, just return empty list
	return values;
}
示例#12
0
/// delete all objects/rows in \c tableName that meet a certain condition. \c whereClause is a string suitable for appending after an SQL "WHERE" term. Returns the number of rows deleted, or 0 if it fails to delete any.
int AMDatabase::deleteRows(const QString& tableName, const QString& whereClause) {

	/// \todo sanitize more than this...
	if(tableName.isEmpty() || whereClause.isEmpty()) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -10, "Could not update the database. (Missing the table name, column, or WHERE clause.)"));
		return 0;
	}

	QSqlDatabase db = qdb();

	if(!db.isOpen()) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -2, "Could not update the database. (Database is not open.)"));
		return 0;
	}

	// Prepare the query (todo: sanitize table name)
	QSqlQuery query(db);
	query.prepare(QString("DELETE FROM %1 WHERE %2").arg(tableName).arg(whereClause));

	// Run query. Query failed?
	if(!execQuery(query)) {
		query.finish();	// make sure that sqlite lock is released before emitting signals
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -3, QString("Failed to delete the database object(s). Could not execute the query (%1). The SQL reply was: %2").arg(query.executedQuery()).arg(query.lastError().text())));
		return 0;
	}

	int numRowsAffected = query.numRowsAffected();

	query.finish();	// make sure that sqlite lock is released before emitting signals
	emit removed(tableName, -1);

	// Query succeeded.
	return numRowsAffected;
}
示例#13
0
/// Changing single values in the database (where the id isn't known).  Will update all rows based on the condition specified. \c whereClause is a string suitable for appending after an SQL "WHERE" term.  Will set the value in \c dataColumn to \c dataValue.
bool AMDatabase::update(const QString& tableName, const QString& whereClause, const QString& dataColumn, const QVariant& dataValue) {

	/// \todo sanitize more than this...
	if(whereClause.isEmpty() || dataColumn.isEmpty() || tableName.isEmpty()) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -10, "Could not complete the database update; missing the table name, column, or WHERE clause."));
		return false;
	}

	QSqlDatabase db = qdb();

	if(!db.isOpen()) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -2, "Could not save to the database. (Database is not open.)"));
		return false;
	}

	// Prepare the query. Todo: sanitize column names and table name. (Can't use binding because it's not an expression here)
	QSqlQuery query(db);
	query.prepare(QString("UPDATE %1 SET %2 = ? WHERE %3").arg(tableName).arg(dataColumn).arg(whereClause));
	query.bindValue(0, dataValue);

	// Run query. Query failed?
	if(!execQuery(query)) {
		query.finish();	// make sure that sqlite lock is released before emitting signals
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -3, QString("Failed to update the database. Could not execute the query (%1). The SQL reply was: %2").arg(query.executedQuery()).arg(query.lastError().text())));
		return false;
	}
	// Query succeeded.
	query.finish();	// make sure that sqlite lock is released before emitting signals
	emit updated(tableName, -1);
	return true;

}
示例#14
0
/// changing single values in the database, at row \c id.
bool AMDatabase::update(int id, const QString& table, const QString& column, const QVariant& value) {

	QSqlDatabase db = qdb();

	if(!db.isOpen()) {
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -2, "Could not save to database. (Database is not open.)"));
		return false;
	}

	// Prepare the query. Todo: sanitize column names and table name. (Can't use binding because it's not an expression here)
	QSqlQuery query(db);
	query.prepare(QString("UPDATE %1 SET %2 = ? WHERE id = ?").arg(table).arg(column));
	query.bindValue(0, value);
	query.bindValue(1, QVariant(id));

	// Run query. Query failed?
	if(!execQuery(query)) {
		query.finish();	// make sure that sqlite lock is released before emitting signals
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -3, QString("database update failed. Could not execute query (%1). The SQL reply was: %2").arg(query.executedQuery()).arg(query.lastError().text())));
		return false;
	}
	// Query succeeded.
	query.finish();	// make sure that sqlite lock is released before emitting signals
	emit updated(table, id);
	return true;

}
示例#15
0
TypeApartment::TypeApartment(QWidget *parent) :
    MainWidget(parent),
    ui(new Ui::TypeApartment),
    mId(-1),
    mIdObjects(-1)
{
    ui->setupUi(this);
    ui->label_2->setProperty("title", "true");
    //ui->mpRooms->setVisible(false);
    //ui->label_7->setVisible(false);

    QStringList vDicts;
    vDicts << "apartment" << "material" << "fund";

    QList<QComboBox*> vBoxes;
    vBoxes << ui->mpApartment << ui->mpMaterial << ui->mpFond;
    for (int i =0; i < vDicts.count(); ++i)
    {
        ResponseType vQuery = execQuery(
                    QString("SELECT id, \"name\" FROM static_dictionaries WHERE parent IN (SELECT id FROM static_dictionaries WHERE parent is NULL AND \"name\" = '%1')")
                     .arg(vDicts.at(i)));
        ResponseRecordType vRecord;
        vBoxes[i]->addItem(TRANSLATE("не выбрано"), -1);
        foreach (vRecord, vQuery)
        {
            vBoxes[i]->addItem(vRecord["name"].toString(), vRecord["id"].toInt());
        }
    }
示例#16
0
void InformationArea::load(int aIdObjects)
{
    MainWidget::load();
    mIdObjects = aIdObjects;
    ResponseType vResponse = execQuery(
                QString("SELECT id, total, floor, kitchen FROM area WHERE object_fk = %1")
                .arg(mIdObjects));
    if (vResponse.count())
    {
        ResponseRecordType vQuery = vResponse[0];

        ui->mpFloor->blockSignals(true);
        ui->mpKitchen->blockSignals(true);
        ui->mpTotal->blockSignals(true);
        mId = vQuery["id"].toInt();
        ui->mpTotal->setText(vQuery["total"].toString());
        ui->mpKitchen->setText(vQuery["kitchen"].toString());
        ui->mpFloor->setText(vQuery["floor"].toString());
        ui->mpFloor->blockSignals(false);
        ui->mpKitchen->blockSignals(false);
        ui->mpTotal->blockSignals(false);
        MainWidget::save();
    }
    else
    {
        mId = -1;
        ui->mpTotal->setText("");
        ui->mpKitchen->setText("");
        ui->mpFloor->setText("");
    }

}
示例#17
0
void QgsSpatialQuery::runQuery( QgsFeatureIds &qsetIndexResult,
                                QgsFeatureIds &qsetIndexInvalidTarget,
                                QgsFeatureIds &qsetIndexInvalidReference,
                                int relation, QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
{
    setQuery( lyrTarget, lyrReference );

    // Create Spatial index for Reference - Set mIndexReference
    mPb->setFormat( QObject::tr( "Processing 1/2 - %p%" ) );
    int totalStep = mUseReferenceSelection
                    ? mLayerReference->selectedFeatureCount()
                    : ( int )( mLayerReference->featureCount() );
    mPb->init( 1, totalStep );
    setSpatialIndexReference( qsetIndexInvalidReference ); // Need set mLayerReference before

    // Make Query
    mPb->setFormat( QObject::tr( "Processing 2/2 - %p%" ) );
    totalStep = mUseTargetSelection
                ? mLayerTarget->selectedFeatureCount()
                : ( int )( mLayerTarget->featureCount() );
    mPb->init( 1, totalStep );

    execQuery( qsetIndexResult, qsetIndexInvalidTarget, relation );

} // QSet<int> QgsSpatialQuery::runQuery( int relation)
	RESULT YandexNarodHTTPConnector::auth()
	{
		bool isConnected = false;
        m_cookies.clear();
		QString header = "";
        QString post = QString::fromAscii("login="******"&passwd=") + m_password;
		QString response;
		int err = execQuery("http://passport.yandex.ru/passport?mode=auth", header, post, &response);
		if(err == 302)
		{
			QString pattern = QString::fromAscii("Set-Cookie: (.*); path");
			QRegExp rx(pattern);
			rx.setCaseSensitivity(Qt::CaseSensitive);
			rx.setMinimal(true);
			rx.setPatternSyntax(QRegExp::RegExp);

			int pos = 0;
			while((pos = rx.indexIn(response, pos)) != -1)
			{
                m_cookies.append(rx.cap(1));
				pos += rx.matchedLength();
			}

            isConnected = err && (m_cookies.count() > 0);
		}

		return !isConnected ? eERROR_GENERAL: eNO_ERROR;
	}
示例#19
0
void TrackerStore::storeVideo(const QString& path) {
#ifdef HARMATTAN
  execQuery(VIDEO_QUERY, path);
#else
  Q_UNUSED(path);
#endif
}
QueryResult QueryDB::getCategorie( QString filtro )
{
    QString query = "select Categoria from Categorie where Categoria like \'%" ;
    query += filtro ;
    query +=  "%\' order by Categoria" ;
    return execQuery( query ) ;
}
示例#21
0
void TrackerStore::storeImage(const QString& path) {
#ifdef HARMATTAN
  execQuery(IMAGE_QUERY, path);
#else
  Q_UNUSED(path);
#endif
}
示例#22
0
bool DbFunc::exec(const QSqlDatabase& db, const QString& sql,
                  const ArgList& args)
{
    // Executes a new query and returns success.
    QSqlQuery query(db);
    return execQuery(query, sql, args);
}
示例#23
0
//! get a value retrieved from Jobs_Vertical_History table
QuillErrCode
PGSQLDatabase::getHistoryVerValue(SQLQuery *queryver, 
								  int row, int col, const char **value)
{
	QuillErrCode st;

	if(row < historyVerFirstRowIndex) {
		dprintf(D_ALWAYS, "ERROR: Trying to access Jobs_Vertical_History\n"); 
		dprintf(D_ALWAYS, "before the start of the current range.\n");
		dprintf(D_ALWAYS, "Backwards iteration is currently not supported\n");
		return FAILURE_QUERY_HISTORYADS_VER;
	}

	else if(row >= historyVerFirstRowIndex + historyVerNumRowsFetched) {
			// fetch more rows into historyVerRes
		if(historyVerRes != NULL) {
			PQclear(historyVerRes);
			historyVerRes = NULL;
		}
		historyVerFirstRowIndex += historyVerNumRowsFetched;

		if((st = execQuery(queryver->getFetchCursorStmt(), 
						   historyVerRes, 
						   historyVerNumRowsFetched)) == QUILL_FAILURE) {
			return FAILURE_QUERY_HISTORYADS_VER;
		}
		if(historyVerNumRowsFetched == 0) {
			return DONE_HISTORY_VER_CURSOR;
		}
	
	}
	*value = PQgetvalue(historyVerRes, row - historyVerFirstRowIndex, col);

	return QUILL_SUCCESS;
}
bool EmployeeTableModel::setActive(const QString& login, bool active)
{
    QSqlQuery q(QSqlDatabase::database("KarbowyDb"));
    q.prepare(setActiveQ);
    q.addBindValue(active);
    q.addBindValue(login);
    return execQuery(q);
}
示例#25
0
int main(int argc, char *argv[])
{
  bool		quiet = false;
  char const *	vserver;
  VserverTag	tag;
  
  while (1) {
    int		c = getopt_long(argc, argv, "ql", CMDLINE_OPTIONS, 0);
    if (c==-1) break;

    switch (c) {
      case 'h'		:  showHelp(1, argv[0], 0);
      case 'v'		:  showVersion();
      case 'l'		:  showTags();
      case 'q'		:  quiet = true; break;
      default		:
	WRITE_MSG(2, "Try '");
	WRITE_STR(2, argv[0]);
	WRITE_MSG(2, " --help' for more information.\n");
	exit(1);
	break;
    }
  }

  if (optind+2>argc) {
    execQuery("-", tgSYSINFO, 0, 0);
    WRITE_MSG(2, "\nAssumed 'SYSINFO' as no other option given; try '--help' for more information.\n");
    exit(0);
  }

  vserver = argv[optind];
  tag     = stringToTag(argv[optind+1]);

  if (tag==tgNONE) {
    WRITE_MSG(2, "Unknown tag; use '-l' to get list of valid tags\n");
    exit(1);
  }

  if (quiet) {
    int		fd = Eopen("/dev/null", O_WRONLY, 0644);
    Edup2(fd, 1);
    Eclose(fd);
  }

  return execQuery(vserver, tag, argc-(optind+2), argv+optind+2);
}
bool EmployeeTableModel::setLogin(const QString& oldLogin, const QString& newLogin)
{
    QSqlQuery q(QSqlDatabase::database("KarbowyDb"));
    q.prepare(setLoginQ);
    q.addBindValue(newLogin);
    q.addBindValue(oldLogin);
    return execQuery(q);
}
bool EmployeeTableModel::setPassword(const QString& login, const QString& password)
{
    QSqlQuery q(QSqlDatabase::database("KarbowyDb"));
    q.prepare(setPasswordQ);
    q.addBindValue(password);
    q.addBindValue(login);
    return execQuery(q);
}
示例#28
0
void InformationArea::save()
{
    if (mId < 0)
    {
        execQuery(QString("INSERT INTO area (object_fk) VALUES (%1)")
                  .arg(mIdObjects));
        mId = execQuery(
                    QString("SELECT id FROM area WHERE object_fk = %1")
                    .arg(mIdObjects))[0]["id"].toInt();
    }
    execQuery(QString("UPDATE area SET total = %1, floor = %2, kitchen = %3 WHERE id = %4")
              .arg(ui->mpTotal->text().isEmpty() ? "0" : ui->mpTotal->text())
              .arg(ui->mpFloor->text().isEmpty() ? "0" : ui->mpFloor->text())
              .arg(ui->mpKitchen->text().isEmpty() ? "0" : ui->mpKitchen->text())
              .arg(mId));
    MainWidget::save();
}
示例#29
0
// Added By Begemot, exact as execScalar but return CString  08/06/06 16:30:37
CString CppSQLite3DB::execScalarStr(LPCTSTR szSQL)
{
	CppSQLite3Query q = execQuery(szSQL);

	if (q.eof() || q.numFields() < 1)
		throw CppSQLite3Exception(CPPSQLITE_ERROR, _T("Invalid scalar query"),	DONT_DELETE_MSG);
	
	return (CString)q.getStringField(0);
}
示例#30
0
int CppSQLite3DB::execScalar(LPCTSTR szSQL)
{
	CppSQLite3Query q = execQuery(szSQL);

	if (q.eof() || q.numFields() < 1)
		throw CppSQLite3Exception(CPPSQLITE_ERROR, _T("Invalid scalar query"),	DONT_DELETE_MSG);

	return _tstoi(q.fieldValue(0));
}