Class: KnjDB_mysql_result
- Defined in:
- lib/knj/knjdb/drivers/mysql/knjdb_mysql.rb
Instance Method Summary collapse
- #each ⇒ Object
- #fetch ⇒ Object
- #fetch_hash_strings ⇒ Object
- #fetch_hash_symbols ⇒ Object
-
#initialize(driver, result) ⇒ KnjDB_mysql_result
constructor
A new instance of KnjDB_mysql_result.
Constructor Details
#initialize(driver, result) ⇒ KnjDB_mysql_result
Returns a new instance of KnjDB_mysql_result.
323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql.rb', line 323 def initialize(driver, result) @driver = driver @result = result @mutex = Mutex.new if @result @keys = [] keys = @result.fetch_fields keys.each do |key| @keys << key.name.to_sym end end end |
Instance Method Details
#each ⇒ Object
366 367 368 369 370 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql.rb', line 366 def each while data = self.fetch_hash_symbols yield(data) end end |
#fetch ⇒ Object
337 338 339 340 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql.rb', line 337 def fetch return self.fetch_hash_symbols if @driver.knjdb.opts[:return_keys] == "symbols" return self.fetch_hash_strings end |
#fetch_hash_strings ⇒ Object
342 343 344 345 346 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql.rb', line 342 def fetch_hash_strings @mutex.synchronize do return @result.fetch_hash end end |
#fetch_hash_symbols ⇒ Object
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql.rb', line 348 def fetch_hash_symbols fetched = nil @mutex.synchronize do fetched = @result.fetch_row end return false if !fetched ret = {} count = 0 @keys.each do |key| ret[key] = fetched[count] count += 1 end return ret end |