libgdamm Reference Documentation

Main Page Namespaces Book

# Gnome::Gda::DataModelQuery Class Reference
[Data Models]

An implementation of DataModel based on a SELECT query. More...

Inheritance diagram for Gnome::Gda::DataModelQuery:

[legend]
List of all members.

## Public Member Functions

bool | compute_modification_queries (const Glib::ustring& target, DataModelQueryOptions options)
| Try to compute the INSERT, DELETE and UPDATE queries; any previous modification query will be discarded.
Glib::RefPtr<const ParameterList> | get_parameter_list () const
| If some parameters are required to execute the SELECT query used in the model data model, then Returns: a Gda::ParameterList object, or `0`.
Glib::RefPtr<ParameterList> | get_parameter_list ()
| If some parameters are required to execute the SELECT query used in the model data model, then Returns: a Gda::ParameterList object, or `0`.
const GdaDataModelQuery* | gobj () const
| Provides access to the underlying C GObject.
GdaDataModelQuery* | gobj ()
| Provides access to the underlying C GObject.
GdaDataModelQuery* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
bool | query_refresh ()
| (Re)-runs the SELECT query to update the contents of model
bool | set_modification_query (const Glib::ustring& query)
| Sets the modification query to be used by model to actually perform any change to the dataset in the database.
virtual | ~DataModelQuery ()

## Static Public Member Functions

static Glib::RefPtr<DataModelQuery> | create (Glib::RefPtr<Query>& query)

## Protected Member Functions

| DataModelQuery (const Glib::RefPtr<Query>& query)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr<Gnome::Gda::DataModelQuery> | wrap (GdaDataModelQuery* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

An implementation of DataModel based on a SELECT query.

The DataModelQuery data model simply stores the values returned by a SELECT query. The connection used to execute the SELECT query (given when the object is constructed) is the same as the one provided the Dict object to which the query relates.

## Constructor & Destructor Documentation

virtual Gnome::Gda::DataModelQuery::~DataModelQuery | ( |  | ) | `[virtual]`

Gnome::Gda::DataModelQuery::DataModelQuery | ( | const Glib::RefPtr<Query>& | query | ) | `[explicit, protected]`

## Member Function Documentation

bool Gnome::Gda::DataModelQuery::compute_modification_queries | ( | const Glib::ustring & | target,
|  | DataModelQueryOptions | options |
| ) |  |  |

Try to compute the INSERT, DELETE and UPDATE queries; any previous modification query will be discarded.

If specified, the table which will be updated is the one represented by the target.

If target is `0`, then an error will be returned if model's SELECT query has more than one target.

Parameters:

  | target | The target table to modify, or `0`.
  | options | Options to specify how the queries must be built in some special cases.

Returns:
  `true` if the INSERT, DELETE and UPDATE queries have been computed.

static Glib::RefPtr<DataModelQuery> Gnome::Gda::DataModelQuery::create | ( | Glib::RefPtr<Query>& | query | ) | `[static]`

Glib::RefPtr<const ParameterList> Gnome::Gda::DataModelQuery::get_parameter_list | ( |  | ) | const

If some parameters are required to execute the SELECT query used in the model data model, then Returns: a Gda::ParameterList object, or `0`.

Returns:
  A Gda::ParameterList object, or `0`.

Glib::RefPtr<ParameterList> Gnome::Gda::DataModelQuery::get_parameter_list | ( |  | ) |

If some parameters are required to execute the SELECT query used in the model data model, then Returns: a Gda::ParameterList object, or `0`.

Returns:
  A Gda::ParameterList object, or `0`.

const GdaDataModelQuery* Gnome::Gda::DataModelQuery::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gnome::Gda::DataModel.

GdaDataModelQuery* Gnome::Gda::DataModelQuery::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gnome::Gda::DataModel.

GdaDataModelQuery* Gnome::Gda::DataModelQuery::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

Reimplemented from Gnome::Gda::Object.

bool Gnome::Gda::DataModelQuery::query_refresh | ( |  | ) |

(Re)-runs the SELECT query to update the contents of model

Returns:
  `true` if no error occurred.

bool Gnome::Gda::DataModelQuery::set_modification_query | ( | const Glib::ustring & | query | ) |

Sets the modification query to be used by model to actually perform any change to the dataset in the database.

The provided query (the query SQL) must be either a INSERT, UPDATE or DELETE query. It can contain parameters, and the parameters named '[+-]<num>' will be replaced when the query is run: <itemizedlist> <listitem>a parameter named +<num> will take the new value set at the <num>th column in model</listitem> <listitem>a parameter named -<num> will take the old value set at the <num>th column in model</listitem> </itemizedlist> Please note that the "+0" and "-0" parameters names are valid and will respectively take the new and old values of the first column of model.

Examples of queries are: "INSERT INTO orders (customer, creation_date, delivery_before, delivery_date) VALUES (## / *name:'Customer' type:integer* /, date('now'), ## / *name:"+2" type:date nullok:`true` * /, `0`)", "DELETE FROM orders WHERE id = ## / *name:"-0" type:integer* /" and "UPDATE orders set id=## / *name:"+0" type:integer* /, delivery_before=## / *name:"+2" type:date nullok:`true`* /, delivery_date=## / *name:"+3" type:date nullok:`true`* / WHERE id=## / *name:"-0" type:integer* /"

Parameters:

  | query | The SQL code for a query.

Returns:
  `true` if no error occurred.

## Friends And Related Function Documentation

Glib::RefPtr<Gnome::Gda::DataModelQuery> wrap | ( | GdaDataModelQuery * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- datamodelquery.h