Beispiel #1
0
int UpdateMarksBySidQuery::bind()
{
    int err = bindInt64( ":sid", m_record.sid );
    if ( !err ) err = bindInt( ":fmark", m_record.fmark );
    if ( !err ) err = bindInt( ":rmark", m_record.rmark );
    return err;
}
Beispiel #2
0
int TranslationUpdateQuery::bind()
{
    int err = bindPrimaryKey();
    if ( !err ) err = bindInt64( ":sid", m_record.sid );
    if ( !err ) err = bindString( ":text", m_record.text );
    if ( !err ) err = bindInt( ":fmark", m_record.fmark );
    if ( !err ) err = bindInt( ":rmark", m_record.rmark );
    return err;
}
Beispiel #3
0
void Sqlite3Database::updateNote(const Note &note)
{
    auto date_str = pt::to_iso_string(note.reminder());

    clearStatement();
    stmt_cache_ << "UPDATE notes SET title=?1,content=?2,"
                << "notebook=?3,last_change=datetime('now','localtime'),"
                << "reminder=?4 where (id=?5)";

    auto result = prepareStatement(stmt_cache_.str());

    bindString(result, 1, note.title());
    bindString(result, 2, note.content());
    bindInt(result, 3, note.notebook());
    bindString(result, 4, date_str);
    bindInt(result, 5, note.id());
    if (isError(executeStep(result)))
        throw DatabaseException("updating note " + note.title() + " failed");
}
Beispiel #4
0
	void TextureShowShader::use(Texture* tex, float layerOrTexcoord)
	{
		//assert(0&&"TextureShowShader::build not implemented yet, hence must fail; TODO");
		assert("TextureShowShader::use(): type of passed Texture and type of initially defined must fit"
				&& ( mTextureType == tex->getTextureType()) );

		GUARD(glUseProgram(mGLProgramHandle));

		//bind texture to sampler
		GUARD(glActiveTexture(GL_TEXTURE0 ));
		GUARD(tex->bind(OPEN_GL_CONTEXT_TYPE));
		bindInt("textureToShow",0);

		//setup orthogonal projection matrix to unit cube:
		//(model and view matrix are the identity here and hence can be ignored)
		bindMatrix4x4("modelViewProjectionMatrix",
				glm::gtc::matrix_transform::ortho(-1.0f,1.0f,-1.0f,1.0f,-1.0f,1.0f));


	}
Beispiel #5
0
// DEMO : sqlite3 example with prepared statement parameters
void Sqlite3Database::newNote(Note &note)
{
    auto date_str = pt::to_iso_string(note.reminder());

    clearStatement();
    stmt_cache_ << "INSERT INTO notes(title,content,notebook,reminder) VALUES("
                << "?1, ?2, ?3, ?4"
                << ")";

    auto result = prepareStatement(stmt_cache_.str());

    bindString(result, 1, note.title());
    bindString(result, 2, note.content());
    bindInt(result, 3, note.notebook());
    bindString(result, 4, date_str);
    if (isError(executeStep(result)))
        throw DatabaseException("inserting note " + note.title() + " failed");

    // get the generated ID
    note.id(getLastInsertId());
}
unique_ptr<SqlStatement> CommonClause::createStatementAndBindValuesToPlaceholders(SqliteDatabase* db, const string& sql) const
{
    auto stmt = db->prepStatement(sql);
    if (stmt == nullptr) return nullptr;

    // bind the actual column values to the placeholders
    int curPlaceholderIdx = 1;   // leftmost placeholder is at position 1
    for (int i=0; i < colVals.size(); ++i)
    {
        const ColValInfo& curCol = colVals[i];

        // NULL or NOT NULL has to handled directly as literal value when
        // creating the sql statement's text
        if ((curCol.type == ColValType::Null) || (curCol.type == ColValType::NotNull)) continue;

        switch (curCol.type)
        {
        case ColValType::Int:
            stmt->bindInt(curPlaceholderIdx, intVals[curCol.indexInList]);
            break;

        case ColValType::Double:
            stmt->bindDouble(curPlaceholderIdx, doubleVals[curCol.indexInList]);
            break;

        case ColValType::String:
            stmt->bindString(curPlaceholderIdx, stringVals[curCol.indexInList]);
            break;

        default:
            throw std::runtime_error("unhandled argument type when binding argument values to statement");
        }

        ++curPlaceholderIdx;
    }

    return stmt;
}
Beispiel #7
0
void RepoQuery::bindBool(const char* paramName, bool b) {
  bindInt(paramName, int(b));
}
Beispiel #8
0
void RepoQuery::bindAttr(const char* paramName, Attr attrs) {
  bindInt(paramName, int(attrs));
}
Beispiel #9
0
void RepoQuery::bindOffset(const char* paramName, Offset offset) {
  bindInt(paramName, int(offset));
}
Beispiel #10
0
void RepoQuery::bindId(const char* paramName, Id id) {
  bindInt(paramName, int(id));
}
Beispiel #11
0
int TranslationIdsByRMarkQuery::bind()
{
    return bindInt( ":rmark", m_rmark );
}