execute is defined on statmenet

This commit is contained in:
Aaron Patterson 2010-07-08 16:05:50 -07:00
parent 2c86f9d72a
commit 7e95b543c9
2 changed files with 21 additions and 0 deletions

View File

@ -42,6 +42,20 @@ static VALUE field_count(VALUE self)
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()
{
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, "param_count", param_count, 0);
rb_define_method(cMysql2Statement, "field_count", field_count, 0);
rb_define_method(cMysql2Statement, "execute", execute, 0);
}

View File

@ -44,4 +44,10 @@ describe Mysql2::Statement do
stmt.prepare 'SELECT 1'
stmt.field_count.should == 1
end
it "should let us execute our statement" do
stmt = @client.create_statement
stmt.prepare 'SELECT 1'
stmt.execute.should == stmt
end
end