execute is defined on statmenet
This commit is contained in:
parent
2c86f9d72a
commit
7e95b543c9
|
@ -42,6 +42,20 @@ static VALUE field_count(VALUE self)
|
||||||
return UINT2NUM(mysql_stmt_field_count(stmt));
|
return UINT2NUM(mysql_stmt_field_count(stmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* call-seq: stmt.execute
|
||||||
|
*
|
||||||
|
* Executes the current prepared statement, returns +stmt+.
|
||||||
|
*/
|
||||||
|
static VALUE execute(VALUE self)
|
||||||
|
{
|
||||||
|
MYSQL_STMT * stmt;
|
||||||
|
Data_Get_Struct(self, MYSQL_STMT, stmt);
|
||||||
|
|
||||||
|
mysql_stmt_execute(stmt);
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
void init_mysql2_statement()
|
void init_mysql2_statement()
|
||||||
{
|
{
|
||||||
cMysql2Statement = rb_define_class_under(mMysql2, "Statement", rb_cObject);
|
cMysql2Statement = rb_define_class_under(mMysql2, "Statement", rb_cObject);
|
||||||
|
@ -49,4 +63,5 @@ void init_mysql2_statement()
|
||||||
rb_define_method(cMysql2Statement, "prepare", prepare, 1);
|
rb_define_method(cMysql2Statement, "prepare", prepare, 1);
|
||||||
rb_define_method(cMysql2Statement, "param_count", param_count, 0);
|
rb_define_method(cMysql2Statement, "param_count", param_count, 0);
|
||||||
rb_define_method(cMysql2Statement, "field_count", field_count, 0);
|
rb_define_method(cMysql2Statement, "field_count", field_count, 0);
|
||||||
|
rb_define_method(cMysql2Statement, "execute", execute, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,4 +44,10 @@ describe Mysql2::Statement do
|
||||||
stmt.prepare 'SELECT 1'
|
stmt.prepare 'SELECT 1'
|
||||||
stmt.field_count.should == 1
|
stmt.field_count.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should let us execute our statement" do
|
||||||
|
stmt = @client.create_statement
|
||||||
|
stmt.prepare 'SELECT 1'
|
||||||
|
stmt.execute.should == stmt
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue