Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

class SqlArray : public ArrayCtrl

SqlArray extends ArrayCtrl to support browsing and editing of SQL tables.

 


 

Callback WhenPreQuery

Invoked before SqlArray issues SQL query to fill its content.

 


 

Callback WhenPostQuery

Invoked after SQL query to fills SqlArray.

 


 

Gate1<const VectorMap<Id, Value>&> WhenFilter

This callback adds additional filtering of records fetched from the database. Only records for whose it returns true are add to the list. The VectorMap parameter contains database column - record value pairs.

 


 

void StdBar(Bar& menu)

Implements standard menu-bar of SqlArray. This menu contains items for inserting, duplicating, editing and removing database table rows. Various items are enabled/disabled according to SqlArray setup.

 


 

bool CanInsert() const

Returns true if it is possible to insert row into database. In reality, this can be false for detail SqlArray in master-detail (see Join) relation when master SqlArray has no row selected (and thus there is no foreign key to bind the record to).

 


 

void StartInsert()

Starts editing of newly inserted row. If there is non-Null value in the key (first index of ArrayCtrl) after the line is inserted into the ArrayCtrl or if AutoInsertId is active the row is inserted into table (using SQL INSERT) immediately even before editing. Accepting or canceling edit then updates or removes the row. Note that non-Null value for such row can be set by InsertValue. AutoInsertId is intended for SQL engines that do support auto-increment columns - in that case, empty row is inserted into the table and its auto-increment value is read to SqlArray.

If above condition is not satisfied, the row is not inserted into database at this moment. In that case, it is inserted only after the row is accepted (typically after closing the editation mode by pressing Enter key). While this seems more logical, however the major disadvantage is that if such table acts as master in master-detail relation, the detail row cannot be inserted (as foreign keys is not yet known) until the line edit is finished, which is contra-intuitive. Note that this 'late insert' mode is usually reserved for tables where key is logical and edited by user.

 

 


 

void StartDuplicate()

Similar to StartInsert, but copies the content of current line to the newly inserted one.

 


 

void DoRemove()

Performs removal of line from SqlArray AND database. If AskRemove is active (default), user is prompted (using PromptYesNo) before removing.

 


 

void SetSession(SqlSession& _session)

Sets the sql session used for. (Default is SQL).

 


 

void Join(SqlId fk, ArrayCtrl& master)

Joins this SqlArray with master using foreign key fk. SqlArray will represent a detail; when cursor in master changes, SqlArray reloads with a query (issuing select to database) formed by (optional) SetWhere SqlBool expression and fk == master.GetKey().

 


 

void Join(ArrayCtrl& master)

Joins master.using the name of key (first index) as foreign key name.

 


 

void Query()

Reloads the content (issuing select).

 


 

void AppendQuery(SqlBool where)

Appends a query with where, adding rows to current content. Foreign keys and master defined by Join are combined with where. This is rather untypical operation.

 


 

void Query(SqlBool where)

Performs SetWhere(where); Query().

 


 

void ReQuery()

Similar to Query, but restores the position of cursor to the row with same key as was active before this operations if possible. Tries to keep relative scroll position as well.

 


 

void Limit(int _offset, int _count)

Allows to fetch only part of query results, on database engines which support it.

 


 

void Limit(int count)

Same as Limit(0, count).

 


 

SqlArray& SetTable(SqlId _table)

Sets the source table for this SqlArray.

 


 

SqlArray& SetTable(SqlId _table, SqlId key)

Sets both the table and the primary key. Same as SetTable(_table); AddKey(key).

 


 

SqlArray& SetWhere(SqlBool where)

Sets the where expression. This expression is combined with foreign key (defined by Join) expression when performing Query.

 


 

SqlArray& SetOrderBy(SqlSet _orderby)

SqlArray& SetOrderBy(const SqlVal& a)

SqlArray& SetOrderBy(const SqlVal& a, const SqlVal& b)

SqlArray& SetOrderBy(const SqlVal& a, const SqlVal& b, const SqlVal& c)

Sets the sorting order - affects "ORDER BY" part of query.

 


 

SqlArray& GoEndPostQuery(bool b = true)

If active, cursor is placed to the last row of SqlArray after the query instead of first one.

 


 

SqlArray& AutoInsertId(bool b = true)

Lets the database engine to create the value for auto-increment keys.

 


 

SqlArray& AppendingAuto()

Combines Appending and AutoInsertId.

 


 

void Clear()

Clears the content.

 


 

void Reset()

Resets SqlArray to initial state - all settings, indexes and columns are removed.

 

Last edit by cxl on 05/09/2013. Do you want to contribute?. T++