Class: Mysql::Stmt
- Inherits:
-
Object
- Object
- Mysql::Stmt
- Defined in:
- ext/mysql_api/mysql.c
Constant Summary collapse
- ATTR_UPDATE_MAX_LENGTH =
INT2NUM(STMT_ATTR_UPDATE_MAX_LENGTH)
Instance Method Summary collapse
-
#affected_rows ⇒ Object
affected_rows().
-
#attr_get(opt) ⇒ Object
attr_get(option).
-
#attr_set(opt, val) ⇒ Object
attr_set(option, arg).
-
#bind_result(*args) ⇒ Object
bind_result(bind,…).
-
#close ⇒ Object
close().
-
#data_seek(offset) ⇒ Object
data_seek(offset).
-
#each ⇒ Object
each ….
-
#execute(*args) ⇒ Object
execute(arg,…).
-
#fetch ⇒ Object
fetch().
-
#field_count ⇒ Object
field_count().
-
#free_result ⇒ Object
free_result().
-
#insert_id ⇒ Object
insert_id().
-
#num_rows ⇒ Object
num_rows().
-
#param_count ⇒ Object
param_count().
-
#prepare(query) ⇒ Object
prepare(query).
-
#reset ⇒ Object
reset().
-
#result_metadata ⇒ Object
result_metadata().
-
#row_seek(offset) ⇒ Object
row_seek(offset).
-
#row_tell ⇒ Object
row_tell().
-
#send_long_data(col, data) ⇒ Object
send_long_data(col, data).
-
#sqlstate ⇒ Object
sqlstate().
Instance Method Details
#affected_rows ⇒ Object
affected_rows()
1265 1266 1267 1268 1269 1270 1271 1272 |
# File 'ext/mysql_api/mysql.c', line 1265
static VALUE stmt_affected_rows(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
my_ulonglong n;
check_stmt_closed(obj);
n = mysql_stmt_affected_rows(s->stmt);
return INT2NUM(n);
}
|
#attr_get(opt) ⇒ Object
attr_get(option)
1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 |
# File 'ext/mysql_api/mysql.c', line 1276
static VALUE stmt_attr_get(VALUE obj, VALUE opt)
{
struct mysql_stmt* s = DATA_PTR(obj);
check_stmt_closed(obj);
if (NUM2INT(opt) == STMT_ATTR_UPDATE_MAX_LENGTH) {
my_bool arg;
mysql_stmt_attr_get(s->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &arg);
return arg == 1 ? Qtrue : Qfalse;
}
rb_raise(eMysql, "unknown option: %d", NUM2INT(opt));
}
|
#attr_set(opt, val) ⇒ Object
attr_set(option, arg)
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 |
# File 'ext/mysql_api/mysql.c', line 1289
static VALUE stmt_attr_set(VALUE obj, VALUE opt, VALUE val)
{
struct mysql_stmt* s = DATA_PTR(obj);
check_stmt_closed(obj);
if (NUM2INT(opt) == STMT_ATTR_UPDATE_MAX_LENGTH) {
my_bool arg;
arg = (val == Qnil || val == Qfalse) ? 0 : 1;
mysql_stmt_attr_set(s->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &arg);
return obj;
}
rb_raise(eMysql, "unknown option: %d", NUM2INT(opt));
}
|
#bind_result(*args) ⇒ Object
bind_result(bind,…)
1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 |
# File 'ext/mysql_api/mysql.c', line 1304
static VALUE stmt_bind_result(int argc, VALUE *argv, VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
int i;
MYSQL_FIELD *field;
check_stmt_closed(obj);
if (argc != s->result.n)
rb_raise(eMysql, "bind_result: result value count(%d) != number of argument(%d)", s->result.n, argc);
for (i = 0; i < argc; i++) {
if (argv[i] == Qnil || argv[i] == rb_cNilClass) {
field = mysql_fetch_fields(s->res);
s->result.bind[i].buffer_type = field[i].type;
}
else if (argv[i] == rb_cString)
s->result.bind[i].buffer_type = MYSQL_TYPE_STRING;
else if (argv[i] == rb_cNumeric || argv[i] == rb_cInteger || argv[i] == rb_cFixnum)
s->result.bind[i].buffer_type = MYSQL_TYPE_LONGLONG;
else if (argv[i] == rb_cFloat)
s->result.bind[i].buffer_type = MYSQL_TYPE_DOUBLE;
else if (argv[i] == cMysqlTime)
s->result.bind[i].buffer_type = MYSQL_TYPE_DATETIME;
else
rb_raise(rb_eTypeError, "unrecognized class: %s", RSTRING_PTR(rb_inspect(argv[i])));
if (mysql_stmt_bind_result(s->stmt, s->result.bind))
mysql_stmt_raise(s->stmt);
}
return obj;
}
|
#close ⇒ Object
close()
1335 1336 1337 1338 1339 1340 1341 1342 |
# File 'ext/mysql_api/mysql.c', line 1335
static VALUE stmt_close(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
check_stmt_closed(obj);
mysql_stmt_close(s->stmt);
s->closed = Qtrue;
return Qnil;
}
|
#data_seek(offset) ⇒ Object
data_seek(offset)
1345 1346 1347 1348 1349 1350 1351 |
# File 'ext/mysql_api/mysql.c', line 1345
static VALUE stmt_data_seek(VALUE obj, VALUE offset)
{
struct mysql_stmt* s = DATA_PTR(obj);
check_stmt_closed(obj);
mysql_stmt_data_seek(s->stmt, NUM2INT(offset));
return obj;
}
|
#each ⇒ Object
each …
1588 1589 1590 1591 1592 1593 1594 1595 |
# File 'ext/mysql_api/mysql.c', line 1588
static VALUE stmt_each(VALUE obj)
{
VALUE row;
check_stmt_closed(obj);
while ((row = stmt_fetch(obj)) != Qnil)
rb_yield(row);
return obj;
}
|
#execute(*args) ⇒ Object
execute(arg,…)
1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 |
# File 'ext/mysql_api/mysql.c', line 1354
static VALUE stmt_execute(int argc, VALUE *argv, VALUE obj)
{
struct mysql_stmt *s = DATA_PTR(obj);
MYSQL_STMT *stmt = s->stmt;
int i;
check_stmt_closed(obj);
free_execute_memory(s);
if (s->param.n != argc)
rb_raise(eMysql, "execute: param_count(%d) != number of argument(%d)", s->param.n, argc);
if (argc > 0) {
memset(s->param.bind, 0, sizeof(*(s->param.bind))*argc);
for (i = 0; i < argc; i++) {
switch (TYPE(argv[i])) {
case T_NIL:
s->param.bind[i].buffer_type = MYSQL_TYPE_NULL;
break;
case T_FIXNUM:
#if SIZEOF_INT < SIZEOF_LONG
s->param.bind[i].buffer_type = MYSQL_TYPE_LONGLONG;
s->param.bind[i].buffer = &(s->param.buffer[i]);
*(LONG_LONG*)(s->param.bind[i].buffer) = FIX2LONG(argv[i]);
#else
s->param.bind[i].buffer_type = MYSQL_TYPE_LONG;
s->param.bind[i].buffer = &(s->param.buffer[i]);
*(int*)(s->param.bind[i].buffer) = FIX2INT(argv[i]);
#endif
break;
case T_BIGNUM:
s->param.bind[i].buffer_type = MYSQL_TYPE_LONGLONG;
s->param.bind[i].buffer = &(s->param.buffer[i]);
*(LONG_LONG*)(s->param.bind[i].buffer) = rb_big2ll(argv[i]);
break;
case T_FLOAT:
s->param.bind[i].buffer_type = MYSQL_TYPE_DOUBLE;
s->param.bind[i].buffer = &(s->param.buffer[i]);
*(double*)(s->param.bind[i].buffer) = NUM2DBL(argv[i]);
break;
case T_STRING:
s->param.bind[i].buffer_type = MYSQL_TYPE_STRING;
s->param.bind[i].buffer = RSTRING_PTR(argv[i]);
s->param.bind[i].buffer_length = RSTRING_LEN(argv[i]);
s->param.length[i] = RSTRING_LEN(argv[i]);
s->param.bind[i].length = &(s->param.length[i]);
break;
default:
if (CLASS_OF(argv[i]) == rb_cTime) {
MYSQL_TIME t;
VALUE a = rb_funcall(argv[i], rb_intern("to_a"), 0);
s->param.bind[i].buffer_type = MYSQL_TYPE_DATETIME;
s->param.bind[i].buffer = &(s->param.buffer[i]);
memset(&t, 0, sizeof(t)); /* avoid warning */
t.second_part = 0;
t.neg = 0;
t.second = FIX2INT(RARRAY_PTR(a)[0]);
t.minute = FIX2INT(RARRAY_PTR(a)[1]);
t.hour = FIX2INT(RARRAY_PTR(a)[2]);
t.day = FIX2INT(RARRAY_PTR(a)[3]);
t.month = FIX2INT(RARRAY_PTR(a)[4]);
t.year = FIX2INT(RARRAY_PTR(a)[5]);
*(MYSQL_TIME*)&(s->param.buffer[i]) = t;
} else if (CLASS_OF(argv[i]) == cMysqlTime) {
MYSQL_TIME t;
s->param.bind[i].buffer_type = MYSQL_TYPE_DATETIME;
s->param.bind[i].buffer = &(s->param.buffer[i]);
memset(&t, 0, sizeof(t)); /* avoid warning */
t.second_part = 0;
t.neg = 0;
t.second = NUM2INT(rb_iv_get(argv[i], "second"));
t.minute = NUM2INT(rb_iv_get(argv[i], "minute"));
t.hour = NUM2INT(rb_iv_get(argv[i], "hour"));
t.day = NUM2INT(rb_iv_get(argv[i], "day"));
t.month = NUM2INT(rb_iv_get(argv[i], "month"));
t.year = NUM2INT(rb_iv_get(argv[i], "year"));
*(MYSQL_TIME*)&(s->param.buffer[i]) = t;
} else
rb_raise(rb_eTypeError, "unsupported type: %d", TYPE(argv[i]));
}
}
if (mysql_stmt_bind_param(stmt, s->param.bind))
mysql_stmt_raise(stmt);
}
if (mysql_stmt_execute(stmt))
mysql_stmt_raise(stmt);
if (s->res) {
MYSQL_FIELD *field;
if (mysql_stmt_store_result(stmt))
mysql_stmt_raise(stmt);
field = mysql_fetch_fields(s->res);
for (i = 0; i < s->result.n; i++) {
switch(s->result.bind[i].buffer_type) {
case MYSQL_TYPE_NULL:
break;
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
s->result.bind[i].buffer = xmalloc(8);
s->result.bind[i].buffer_length = 8;
memset(s->result.bind[i].buffer, 0, 8);
break;
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
#if MYSQL_VERSION_ID >= 50003
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_BIT:
#endif
s->result.bind[i].buffer = xmalloc(field[i].max_length);
memset(s->result.bind[i].buffer, 0, field[i].max_length);
s->result.bind[i].buffer_length = field[i].max_length;
break;
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP:
s->result.bind[i].buffer = xmalloc(sizeof(MYSQL_TIME));
s->result.bind[i].buffer_length = sizeof(MYSQL_TIME);
memset(s->result.bind[i].buffer, 0, sizeof(MYSQL_TIME));
break;
default:
rb_raise(rb_eTypeError, "unknown buffer_type: %d", s->result.bind[i].buffer_type);
}
}
if (mysql_stmt_bind_result(s->stmt, s->result.bind))
mysql_stmt_raise(s->stmt);
}
return obj;
}
|
#fetch ⇒ Object
fetch()
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 |
# File 'ext/mysql_api/mysql.c', line 1494
static VALUE stmt_fetch(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
VALUE ret;
int i;
int r;
check_stmt_closed(obj);
r = mysql_stmt_fetch(s->stmt);
if (r == MYSQL_NO_DATA)
return Qnil;
#ifdef MYSQL_DATA_TRUNCATED
if (r == MYSQL_DATA_TRUNCATED)
rb_raise(rb_eRuntimeError, "unexpectedly data truncated");
#endif
if (r == 1)
mysql_stmt_raise(s->stmt);
ret = rb_ary_new2(s->result.n);
for (i = 0; i < s->result.n; i++) {
if (s->result.is_null[i])
rb_ary_push(ret, Qnil);
else {
VALUE v;
MYSQL_TIME *t;
switch (s->result.bind[i].buffer_type) {
case MYSQL_TYPE_TINY:
if (s->result.bind[i].is_unsigned)
v = UINT2NUM(*(unsigned char *)s->result.bind[i].buffer);
else
v = INT2NUM(*(signed char *)s->result.bind[i].buffer);
break;
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_YEAR:
if (s->result.bind[i].is_unsigned)
v = UINT2NUM(*(unsigned short *)s->result.bind[i].buffer);
else
v = INT2NUM(*(short *)s->result.bind[i].buffer);
break;
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_LONG:
if (s->result.bind[i].is_unsigned)
v = UINT2NUM(*(unsigned int *)s->result.bind[i].buffer);
else
v = INT2NUM(*(int *)s->result.bind[i].buffer);
break;
case MYSQL_TYPE_LONGLONG:
if (s->result.bind[i].is_unsigned)
v = ULL2NUM(*(unsigned long long *)s->result.bind[i].buffer);
else
v = LL2NUM(*(long long *)s->result.bind[i].buffer);
break;
case MYSQL_TYPE_FLOAT:
v = rb_float_new((double)(*(float *)s->result.bind[i].buffer));
break;
case MYSQL_TYPE_DOUBLE:
v = rb_float_new(*(double *)s->result.bind[i].buffer);
break;
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP:
t = (MYSQL_TIME *)s->result.bind[i].buffer;
v = rb_obj_alloc(cMysqlTime);
rb_funcall(v, rb_intern("initialize"), 8,
INT2FIX(t->year), INT2FIX(t->month),
INT2FIX(t->day), INT2FIX(t->hour),
INT2FIX(t->minute), INT2FIX(t->second),
(t->neg ? Qtrue : Qfalse),
INT2FIX(t->second_part));
break;
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
#if MYSQL_VERSION_ID >= 50003
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_BIT:
#endif
v = rb_tainted_str_new(s->result.bind[i].buffer, s->result.length[i]);
break;
default:
rb_raise(rb_eTypeError, "unknown buffer_type: %d", s->result.bind[i].buffer_type);
}
rb_ary_push(ret, v);
}
}
return ret;
}
|
#field_count ⇒ Object
field_count()
1598 1599 1600 1601 1602 1603 1604 1605 |
# File 'ext/mysql_api/mysql.c', line 1598
static VALUE stmt_field_count(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
unsigned int n;
check_stmt_closed(obj);
n = mysql_stmt_field_count(s->stmt);
return INT2NUM(n);
}
|
#free_result ⇒ Object
free_result()
1608 1609 1610 1611 1612 1613 1614 1615 |
# File 'ext/mysql_api/mysql.c', line 1608
static VALUE stmt_free_result(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
check_stmt_closed(obj);
if (mysql_stmt_free_result(s->stmt))
mysql_stmt_raise(s->stmt);
return obj;
}
|
#insert_id ⇒ Object
insert_id()
1618 1619 1620 1621 1622 1623 1624 1625 |
# File 'ext/mysql_api/mysql.c', line 1618
static VALUE stmt_insert_id(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
my_ulonglong n;
check_stmt_closed(obj);
n = mysql_stmt_insert_id(s->stmt);
return INT2NUM(n);
}
|
#num_rows ⇒ Object
num_rows()
1628 1629 1630 1631 1632 1633 1634 1635 |
# File 'ext/mysql_api/mysql.c', line 1628
static VALUE stmt_num_rows(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
my_ulonglong n;
check_stmt_closed(obj);
n = mysql_stmt_num_rows(s->stmt);
return INT2NUM(n);
}
|
#param_count ⇒ Object
param_count()
1638 1639 1640 1641 1642 1643 1644 1645 |
# File 'ext/mysql_api/mysql.c', line 1638
static VALUE stmt_param_count(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
unsigned long n;
check_stmt_closed(obj);
n = mysql_stmt_param_count(s->stmt);
return INT2NUM(n);
}
|
#prepare(query) ⇒ Object
prepare(query)
1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 |
# File 'ext/mysql_api/mysql.c', line 1648
static VALUE stmt_prepare(VALUE obj, VALUE query)
{
struct mysql_stmt* s = DATA_PTR(obj);
int n;
int i;
MYSQL_FIELD *field;
free_mysqlstmt_memory(s);
check_stmt_closed(obj);
Check_Type(query, T_STRING);
if (mysql_stmt_prepare(s->stmt, RSTRING_PTR(query), RSTRING_LEN(query)))
mysql_stmt_raise(s->stmt);
n = mysql_stmt_param_count(s->stmt);
s->param.n = n;
s->param.bind = xmalloc(sizeof(s->param.bind[0]) * n);
s->param.length = xmalloc(sizeof(s->param.length[0]) * n);
s->param.buffer = xmalloc(sizeof(s->param.buffer[0]) * n);
s->res = mysql_stmt_result_metadata(s->stmt);
if (s->res) {
n = s->result.n = mysql_num_fields(s->res);
s->result.bind = xmalloc(sizeof(s->result.bind[0]) * n);
s->result.is_null = xmalloc(sizeof(s->result.is_null[0]) * n);
s->result.length = xmalloc(sizeof(s->result.length[0]) * n);
field = mysql_fetch_fields(s->res);
memset(s->result.bind, 0, sizeof(s->result.bind[0]) * n);
for (i = 0; i < n; i++) {
s->result.bind[i].buffer_type = field[i].type;
#if MYSQL_VERSION_ID < 50003
if (field[i].type == MYSQL_TYPE_DECIMAL)
s->result.bind[i].buffer_type = MYSQL_TYPE_STRING;
#endif
s->result.bind[i].is_null = &(s->result.is_null[i]);
s->result.bind[i].length = &(s->result.length[i]);
s->result.bind[i].is_unsigned = ((field[i].flags & UNSIGNED_FLAG) != 0);
}
} else {
if (mysql_stmt_errno(s->stmt))
mysql_stmt_raise(s->stmt);
}
return obj;
}
|
#reset ⇒ Object
reset()
1695 1696 1697 1698 1699 1700 1701 1702 |
# File 'ext/mysql_api/mysql.c', line 1695
static VALUE stmt_reset(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
check_stmt_closed(obj);
if (mysql_stmt_reset(s->stmt))
mysql_stmt_raise(s->stmt);
return obj;
}
|
#result_metadata ⇒ Object
result_metadata()
1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 |
# File 'ext/mysql_api/mysql.c', line 1706
static VALUE stmt_result_metadata(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
MYSQL_RES *res;
check_stmt_closed(obj);
res = mysql_stmt_result_metadata(s->stmt);
if (res == NULL) {
if (mysql_stmt_errno(s->stmt) != 0)
mysql_stmt_raise(s->stmt);
return Qnil;
}
return mysqlres2obj(res);
}
|
#row_seek(offset) ⇒ Object
row_seek(offset)
1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 |
# File 'ext/mysql_api/mysql.c', line 1721
static VALUE stmt_row_seek(VALUE obj, VALUE offset)
{
struct mysql_stmt* s = DATA_PTR(obj);
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_stmt_closed(obj);
prev_offset = mysql_stmt_row_seek(s->stmt, DATA_PTR(offset));
return Data_Wrap_Struct(cMysqlRowOffset, 0, NULL, prev_offset);
}
|
#row_tell ⇒ Object
row_tell()
1733 1734 1735 1736 1737 1738 1739 1740 |
# File 'ext/mysql_api/mysql.c', line 1733
static VALUE stmt_row_tell(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
MYSQL_ROW_OFFSET offset;
check_stmt_closed(obj);
offset = mysql_stmt_row_tell(s->stmt);
return Data_Wrap_Struct(cMysqlRowOffset, 0, NULL, offset);
}
|
#send_long_data(col, data) ⇒ Object
send_long_data(col, data)
1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 |
# File 'ext/mysql_api/mysql.c', line 1744
static VALUE stmt_send_long_data(VALUE obj, VALUE col, VALUE data)
{
struct mysql_stmt* s = DATA_PTR(obj);
int c;
check_stmt_closed(obj);
c = NUM2INT(col);
if (0 <= c && c < s->param.n) {
s->param.bind[c].buffer_type = MYSQL_TYPE_STRING;
if (mysql_stmt_bind_param(s->stmt, s->param.bind))
mysql_stmt_raise(s->stmt);
}
if (mysql_stmt_send_long_data(s->stmt, c, RSTRING_PTR(data), RSTRING_LEN(data)))
mysql_stmt_raise(s->stmt);
return obj;
}
|
#sqlstate ⇒ Object
sqlstate()
1762 1763 1764 1765 1766 |
# File 'ext/mysql_api/mysql.c', line 1762
static VALUE stmt_sqlstate(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
return rb_tainted_str_new2(mysql_stmt_sqlstate(s->stmt));
}
|