ladybug::

PreparedStatement class

Public Instance Methods

bind_variable( name, value )

Binds the given value to the given parameter name in the prepared statement

static VALUE
rlbug_prepared_statement_bind_variable( VALUE self, VALUE name, VALUE value )
{
        rlbug_prepared_statement *stmt = CHECK_PREPARED_STATEMENT( self );
        VALUE name_string = rb_funcall( name, rb_intern("to_s"), 0 );
        const char *name_s = StringValueCStr( name_string );
        lbug_value *null_value;

        switch (TYPE(value)) {
                case T_TRUE:
                case T_FALSE:
                        lbug_prepared_statement_bind_bool( &stmt->statement, name_s, RTEST(value) );
                        break;

                // fallthrough
                case T_FLOAT:
                        lbug_prepared_statement_bind_float( &stmt->statement, name_s, NUM2DBL(value) );
                        break;

                case T_BIGNUM:
                        lbug_prepared_statement_bind_int64( &stmt->statement, name_s, NUM2LL(value) );
                        break;

                case T_FIXNUM:
                        lbug_prepared_statement_bind_int32( &stmt->statement, name_s, NUM2INT(value) );
                        break;

                case T_SYMBOL:
                        rb_notimplement();
                        break; // not reached

                case T_NIL:
                        null_value = lbug_value_create_null();
                        lbug_prepared_statement_bind_value( &stmt->statement, name_s, null_value );
                        lbug_value_destroy( null_value );
                        break;

                case T_OBJECT:
                case T_CLASS:
                case T_MODULE:
                case T_REGEXP:
                case T_ARRAY:
                case T_HASH:
                case T_STRUCT:
                case T_COMPLEX:
                case T_RATIONAL:
                case T_FILE:
                case T_DATA:
                case T_STRING:
                default:
                        rlbug_bind_string( stmt, name_s, value );
                        break;

                        // lbug_prepared_statement_bind_int8
                        // lbug_prepared_statement_bind_int16
                        // lbug_prepared_statement_bind_uint64
                        // lbug_prepared_statement_bind_uint32
                        // lbug_prepared_statement_bind_uint16
                        // lbug_prepared_statement_bind_uint8

                        // lbug_prepared_statement_bind_double
                        // lbug_prepared_statement_bind_date
                        // lbug_prepared_statement_bind_timestamp_ns
                        // lbug_prepared_statement_bind_timestamp_sec
                        // lbug_prepared_statement_bind_timestamp_tz
                        // lbug_prepared_statement_bind_timestamp_ms
                        // lbug_prepared_statement_bind_timestamp
                        // lbug_prepared_statement_bind_interval
                        // lbug_prepared_statement_bind_value
        }

        return Qtrue;
}
connection → conn

Return the Ladybug::Connection used to run this statement.

static VALUE
rlbug_prepared_statement_connection( VALUE self )
{
        rlbug_prepared_statement *statement_s = rlbug_get_prepared_statement( self );
        return statement_s->connection;
}
query → string

Return the query string used to build this statement.

static VALUE
rlbug_prepared_statement_query( VALUE self )
{
        rlbug_prepared_statement *statement_s = rlbug_get_prepared_statement( self );
        return statement_s->query;
}
success? → true or false

Returns true if the query was prepared successfully.

static VALUE
rlbug_prepared_statement_success_p( VALUE self )
{
        rlbug_prepared_statement *stmt = CHECK_PREPARED_STATEMENT( self );

        if ( lbug_prepared_statement_is_success(&stmt->statement) ) {
                return Qtrue;
        } else {
                return Qfalse;
        }
}