Class: Mysql::Result
- Inherits:
-
Object
- Object
- Mysql::Result
- Defined in:
- ext/mysql.c
Instance Method Summary collapse
-
#data_seek(offset) ⇒ Object
data_seek(offset).
-
#each ⇒ Object
each ….
-
#each_hash(*args) ⇒ Object
each_hash(with_table=false) ….
-
#fetch_field ⇒ Object
fetch_field().
-
#fetch_field_direct(nr) ⇒ Object
fetch_field_direct(nr).
-
#fetch_fields ⇒ Object
fetch_fields().
-
#fetch_hash(*args) ⇒ Object
fetch_hash(with_table=false).
-
#fetch_lengths ⇒ Object
fetch_lengths().
-
#fetch_row ⇒ Object
fetch_row().
-
#field_seek(offset) ⇒ Object
field_seek(offset).
-
#field_tell ⇒ Object
field_tell().
-
#free ⇒ Object
free().
-
#num_fields ⇒ Object
num_fields().
-
#num_rows ⇒ Object
num_rows().
-
#row_seek(offset) ⇒ Object
row_seek(offset).
-
#row_tell ⇒ Object
row_tell().
Instance Method Details
#data_seek(offset) ⇒ Object
data_seek(offset)
941 942 943 944 945 946 |
# File 'ext/mysql.c', line 941
static VALUE data_seek(VALUE obj, VALUE offset)
{
check_free(obj);
mysql_data_seek(GetMysqlRes(obj), NUM2INT(offset));
return obj;
}
|
#each ⇒ Object
each …
1153 1154 1155 1156 1157 1158 1159 1160 |
# File 'ext/mysql.c', line 1153
static VALUE each(VALUE obj)
{
VALUE row;
check_free(obj);
while ((row = fetch_row(obj)) != Qnil)
rb_yield(row);
return obj;
}
|
#each_hash(*args) ⇒ Object
each_hash(with_table=false) …
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 |
# File 'ext/mysql.c', line 1163
static VALUE each_hash(int argc, VALUE* argv, VALUE obj)
{
VALUE with_table;
VALUE hash;
check_free(obj);
rb_scan_args(argc, argv, "01", &with_table);
if (with_table == Qnil)
with_table = Qfalse;
while ((hash = fetch_hash2(obj, with_table)) != Qnil)
rb_yield(hash);
return obj;
}
|
#fetch_field ⇒ Object
fetch_field()
949 950 951 952 953 |
# File 'ext/mysql.c', line 949
static VALUE fetch_field(VALUE obj)
{
check_free(obj);
return make_field_obj(mysql_fetch_field(GetMysqlRes(obj)));
}
|
#fetch_field_direct(nr) ⇒ Object
fetch_field_direct(nr)
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 |
# File 'ext/mysql.c', line 974
static VALUE fetch_field_direct(VALUE obj, VALUE nr)
{
MYSQL_RES* res;
unsigned int max;
unsigned int n;
check_free(obj);
res = GetMysqlRes(obj);
max = mysql_num_fields(res);
n = NUM2INT(nr);
if (n >= max)
rb_raise(eMysql, "%d: out of range (max: %d)", n, max-1);
#if MYSQL_VERSION_ID >= 32226
return make_field_obj(mysql_fetch_field_direct(res, n));
#else
return make_field_obj(&mysql_fetch_field_direct(res, n));
#endif
}
|
#fetch_fields ⇒ Object
fetch_fields()
956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 |
# File 'ext/mysql.c', line 956
static VALUE fetch_fields(VALUE obj)
{
MYSQL_RES* res;
MYSQL_FIELD* f;
unsigned int n;
VALUE ret;
unsigned int i;
check_free(obj);
res = GetMysqlRes(obj);
f = mysql_fetch_fields(res);
n = mysql_num_fields(res);
ret = rb_ary_new2(n);
for (i=0; i<n; i++)
rb_ary_store(ret, i, make_field_obj(&f[i]));
return ret;
}
|
#fetch_hash(*args) ⇒ Object
fetch_hash(with_table=false)
1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'ext/mysql.c', line 1083
static VALUE fetch_hash(int argc, VALUE* argv, VALUE obj)
{
VALUE with_table;
check_free(obj);
rb_scan_args(argc, argv, "01", &with_table);
if (with_table == Qnil)
with_table = Qfalse;
return fetch_hash2(obj, with_table);
}
|
#fetch_lengths ⇒ Object
fetch_lengths()
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 |
# File 'ext/mysql.c', line 993
static VALUE fetch_lengths(VALUE obj)
{
MYSQL_RES* res;
unsigned int n;
unsigned long* lengths;
VALUE ary;
unsigned int i;
check_free(obj);
res = GetMysqlRes(obj);
n = mysql_num_fields(res);
lengths = mysql_fetch_lengths(res);
if (lengths == NULL)
return Qnil;
ary = rb_ary_new2(n);
for (i=0; i<n; i++)
rb_ary_store(ary, i, INT2NUM(lengths[i]));
return ary;
}
|
#fetch_row ⇒ Object
fetch_row()
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 |
# File 'ext/mysql.c', line 1013
static VALUE fetch_row(VALUE obj)
{
MYSQL_RES* res;
unsigned int n;
MYSQL_ROW row;
unsigned long* lengths;
VALUE ary;
unsigned int i;
check_free(obj);
res = GetMysqlRes(obj);
n = mysql_num_fields(res);
row = mysql_fetch_row(res);
lengths = mysql_fetch_lengths(res);
if (row == NULL)
return Qnil;
ary = rb_ary_new2(n);
for (i=0; i<n; i++)
rb_ary_store(ary, i, row[i]? rb_tainted_str_new(row[i], lengths[i]): Qnil);
return ary;
}
|
#field_seek(offset) ⇒ Object
field_seek(offset)
1094 1095 1096 1097 1098 |
# File 'ext/mysql.c', line 1094
static VALUE field_seek(VALUE obj, VALUE offset)
{
check_free(obj);
return INT2NUM(mysql_field_seek(GetMysqlRes(obj), NUM2INT(offset)));
}
|
#field_tell ⇒ Object
field_tell()
1101 1102 1103 1104 1105 |
# File 'ext/mysql.c', line 1101
static VALUE field_tell(VALUE obj)
{
check_free(obj);
return INT2NUM(mysql_field_tell(GetMysqlRes(obj)));
}
|
#free ⇒ Object
free()
1108 1109 1110 1111 1112 1113 1114 1115 1116 |
# File 'ext/mysql.c', line 1108
static VALUE res_free(VALUE obj)
{
struct mysql_res* resp = DATA_PTR(obj);
check_free(obj);
mysql_free_result(resp->res);
resp->freed = Qtrue;
store_result_count--;
return Qnil;
}
|
#num_fields ⇒ Object
num_fields()
1119 1120 1121 1122 1123 |
# File 'ext/mysql.c', line 1119
static VALUE num_fields(VALUE obj)
{
check_free(obj);
return INT2NUM(mysql_num_fields(GetMysqlRes(obj)));
}
|
#num_rows ⇒ Object
num_rows()
1126 1127 1128 1129 1130 |
# File 'ext/mysql.c', line 1126
static VALUE num_rows(VALUE obj)
{
check_free(obj);
return INT2NUM(mysql_num_rows(GetMysqlRes(obj)));
}
|
#row_seek(offset) ⇒ Object
row_seek(offset)
1133 1134 1135 1136 1137 1138 1139 1140 1141 |
# File 'ext/mysql.c', line 1133
static VALUE row_seek(VALUE obj, VALUE offset)
{
MYSQL_ROW_OFFSET prev_offset;
if (CLASS_OF(offset) != cMysqlRowOffset)
rb_raise(rb_eTypeError, "wrong argument type %s (expected Mysql::RowOffset)", rb_obj_classname(offset));
check_free(obj);
prev_offset = mysql_row_seek(GetMysqlRes(obj), DATA_PTR(offset));
return Data_Wrap_Struct(cMysqlRowOffset, 0, NULL, prev_offset);
}
|
#row_tell ⇒ Object
row_tell()
1144 1145 1146 1147 1148 1149 1150 |
# File 'ext/mysql.c', line 1144
static VALUE row_tell(VALUE obj)
{
MYSQL_ROW_OFFSET offset;
check_free(obj);
offset = mysql_row_tell(GetMysqlRes(obj));
return Data_Wrap_Struct(cMysqlRowOffset, 0, NULL, offset);
}
|