Method: Mysql#list_dbs
- Defined in:
- ext/mysql_api/mysql.c
#list_dbs(*args) ⇒ Object
list_dbs(db=nil)
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'ext/mysql_api/mysql.c', line 576
static VALUE list_dbs(int argc, VALUE* argv, VALUE obj)
{
unsigned int i, n;
VALUE db, ret;
MYSQL* m = GetHandler(obj);
MYSQL_RES* res;
rb_scan_args(argc, argv, "01", &db);
res = mysql_list_dbs(m, NILorSTRING(db));
if (res == NULL)
mysql_raise(m);
n = mysql_num_rows(res);
ret = rb_ary_new2(n);
for (i=0; i<n; i++)
rb_ary_store(ret, i, rb_tainted_str_new2(mysql_fetch_row(res)[0]));
mysql_free_result(res);
return ret;
}
|