int CMySQLDynamicRecordSet::MovePrevious() { if(m_hStmt) { if(m_CacheAllData) { MYSQL_ROW_OFFSET Offset=mysql_stmt_row_tell(m_hStmt); Offset--; mysql_stmt_row_seek(m_hStmt,Offset); int Ret=FetchRow(); if(Ret==DBERR_NO_RECORDS) { m_IsBOF=true; return DBERR_IS_RECORDSET_HEAD; } else { return Ret; } } else { return DBERR_NOT_IMPLEMENT; } } else { return DBERR_NO_RECORDS; } }
VALUE db_mysql_result_from_statement_each(VALUE self) { int n; size_t row = 0; VALUE tuple; Result *r; MYSQL_STMT *s; r = db_mysql_result_handle(self); s = db_mysql_statement_handle_safe(r->statement)->statement; mysql_stmt_row_seek(s, r->start); while (row < r->selected) { switch (mysql_stmt_fetch(s)) { case MYSQL_NO_DATA: break; case MYSQL_DATA_TRUNCATED: rb_raise(eSwiftRuntimeError, "Bind buffers were under-allocated: MySQL data truncated"); break; case 1: rb_raise(eSwiftRuntimeError, "%s", mysql_stmt_error(s)); break; default: tuple = rb_hash_new(); for (n = 0; n < RARRAY_LEN(r->fields); n++) { if (r->is_null[n]) { rb_hash_aset(tuple, rb_ary_entry(r->fields, n), Qnil); } else { rb_hash_aset(tuple, rb_ary_entry(r->fields, n), db_mysql_binary_typecast(r, n)); } } rb_yield(tuple); } row++; } return Qtrue; }