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; }
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; }
void Sqlite3Database::updateNote(const Note ¬e) { 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"); }
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)); }
// DEMO : sqlite3 example with prepared statement parameters void Sqlite3Database::newNote(Note ¬e) { 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; }
void RepoQuery::bindBool(const char* paramName, bool b) { bindInt(paramName, int(b)); }
void RepoQuery::bindAttr(const char* paramName, Attr attrs) { bindInt(paramName, int(attrs)); }
void RepoQuery::bindOffset(const char* paramName, Offset offset) { bindInt(paramName, int(offset)); }
void RepoQuery::bindId(const char* paramName, Id id) { bindInt(paramName, int(id)); }
int TranslationIdsByRMarkQuery::bind() { return bindInt( ":rmark", m_rmark ); }