/* Execute an SQL statement. Return a Cursor object if the statement is a query, otherwise return the number of tuples affected by the statement.  */
static int conn_execute(lua_State *L)
/* Execute an SQL statement. Return a Cursor object if the statement is a query, otherwise return the number of tuples affected by the statement.  */
static int conn_execute(lua_State *L)
{
		MYSQL_RES *res = mysql_store_result(conn->my_conn);
		unsigned int num_cols = mysql_field_count(conn->my_conn);
		if (res) {
			return create_cursor (L, 1, res, num_cols);
		}
		else {
			if(num_cols == 0) {
				lua_pushnumber(L, mysql_affected_rows(conn->my_conn));
				return 1;
        	}
			else
				return luasql_failmessage(L, "Error retrieving result. MySQL: ", mysql_error(conn->my_conn));
		}
	}
}