GnuCash  5.6-150-g038405b370+
Public Member Functions
GncSqlOrderBackend Class Reference
Inheritance diagram for GncSqlOrderBackend:
GncSqlObjectBackend

Public Member Functions

void load_all (GncSqlBackend *) override
 Load all objects of m_type in the database into memory. More...
 
bool write (GncSqlBackend *) override
 Write all objects of m_type_name to the database. More...
 
- Public Member Functions inherited from GncSqlObjectBackend
 GncSqlObjectBackend (int version, const std::string &type, const std::string &table, const EntryVec &vec)
 
virtual void create_tables (GncSqlBackend *sql_be)
 Conditionally create or update a database table from m_col_table. More...
 
virtual bool commit (GncSqlBackend *sql_be, QofInstance *inst)
 UPDATE/INSERT a single instance of m_type_name into the database. More...
 
const char * type () const noexcept
 Return the m_type_name for the class. More...
 
const bool is_version (int version) const noexcept
 Compare a version with the compiled version (m_version). More...
 
bool instance_in_db (const GncSqlBackend *sql_be, QofInstance *inst) const noexcept
 Check the presence of an object in the backend's database. More...
 

Additional Inherited Members

- Protected Attributes inherited from GncSqlObjectBackend
const std::string m_table_name
 
const int m_version
 
const std::string m_type_name
 
const EntryVec & m_col_table
 The front-end QofIdType.
 

Detailed Description

Definition at line 35 of file gnc-order-sql.h.

Member Function Documentation

◆ load_all()

void GncSqlOrderBackend::load_all ( GncSqlBackend sql_be)
overridevirtual

Load all objects of m_type in the database into memory.

Parameters
sql_beThe GncSqlBackend containing the database connection.

Implements GncSqlObjectBackend.

Definition at line 106 of file gnc-order-sql.cpp.

107 {
108  g_return_if_fail (sql_be != NULL);
109 
110  std::string sql("SELECT * FROM " TABLE_NAME);
111  auto stmt = sql_be->create_statement_from_sql(sql);
112  auto result = sql_be->execute_select_statement(stmt);
113 
114  for (auto row : *result)
115  load_single_order (sql_be, row);
116 
117  std::string pkey(col_table[0]->name());
118  sql = "SELECT DISTINCT ";
119  sql += pkey + " FROM " TABLE_NAME;
121  (BookLookupFn)gnc_order_lookup);
122 }
GncSqlResultPtr execute_select_statement(const GncSqlStatementPtr &stmt) const noexcept
Executes an SQL SELECT statement and returns the result rows.
void gnc_sql_slots_load_for_sql_subquery(GncSqlBackend *sql_be, const std::string subquery, BookLookupFn lookup_fn)
gnc_sql_slots_load_for_sql_subquery - Loads slots for all objects whose guid is supplied by a subquer...

◆ write()

bool GncSqlOrderBackend::write ( GncSqlBackend sql_be)
overridevirtual

Write all objects of m_type_name to the database.

Parameters
sql_beThe GncSqlBackend containing the database.
Returns
true if the objects were successfully written, false otherwise.

Reimplemented from GncSqlObjectBackend.

Definition at line 158 of file gnc-order-sql.cpp.

159 {
160  g_return_val_if_fail (sql_be != NULL, FALSE);
161  write_objects_t data{sql_be, true, this};
162 
163  qof_object_foreach (GNC_ID_ORDER, sql_be->book(), write_single_order, &data);
164 
165  return data.is_ok;
166 }
void qof_object_foreach(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
Invoke the callback 'cb' on every instance ov a particular object type.
Definition: qofobject.cpp:185
Data-passing struct for callbacks to qof_object_foreach() used in GncSqlObjectBackend::write().

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