MySqlResult class
Wrapper class for MySQL query results with convenient access methods.
This class encapsulates MySQL query results and provides a consistent interface for accessing result data, metadata, and handling errors. It wraps the native MySQL client's IResultSet with additional convenience methods and error handling.
The class provides both low-level access to result set data and high-level convenience methods for common operations like getting associative arrays and checking success status.
Example:
var result = await table.select(conn, query);
if (result.success) {
for (var row in result.assoc) {
print('User: ${row['name']} - ${row['email']}');
}
} else {
print('Query failed: ${result.errorMsg}');
}
Constructors
- MySqlResult.new(IResultSet resultSet, {String errorMsg = ''})
- Creates a new MySqlResult instance.
Properties
- affectedRows → BigInt
-
Returns the number of rows affected by the last INSERT, UPDATE, or DELETE.
no setter
-
assoc
→ List<
Map< String, dynamic> > -
Returns all rows as a list of associative arrays.
no setter
-
assocFirst
→ Map<
String, dynamic> ? -
Returns the first row as an associative array, or null if no rows exist.
no setter
- countRecords → int
-
Returns the count of records from results with the field
count_records
.no setter - error → bool
-
Returns
true
if the query failed (has an error message).no setter - errorMsg ↔ String
-
Error message if the query failed, empty string if successful.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- insertId → BigInt
-
Returns the auto-generated ID from the last INSERT operation.
no setter
- numFields → int
-
Returns the number of columns in the result set.
no setter
- numRows → int
-
Returns the number of rows in the result set.
no setter
- resultSet → IResultSet
-
The underlying MySQL result set from the database driver.
final
-
rows
→ Iterable<
ResultSetRow> -
Returns an iterable of result set rows.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- success → bool
-
Returns
true
if the query executed successfully (no error message).no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited