Introduction

StactiveRecord is a C++ library designed to make simple database use simple. It was inspired by Ruby on Rail's Active Record, however, no similar look, feel, or performance is guaranteed. It uses an Object-relational mapping pattern to represent records as objects. It also provides persistent (basic) object relationships (one to many, many to many, one to one).

Quick Example For Those In A Rush

See the simple example description page for more detailed example.

#include <stactive_record.h>
#include <iostream>
using namespace stactiverecord;
using namespace std;

Sar_Dbi * Sar_Dbi::dbi = Sar_Dbi::makeStorage("sqlite://:memory:");
class Person : public Record<Person> {
public:
  static string classname;
  Person() : Record<Person>() {};
  Person(int id) : Record<Person>(id) {};
  void sayhi() {
    cout << "Hello\n";
  };
};
string Person::classname = "person";

int main() {
  Person bob;
  bob.set("fullname", "Robert Somethingorother");
  bob.set("age", 50);
  bob.save();

  ObjGroup<Person> people = Person::find(Q("age", between(40, 100)) && Q("fullname", startswith("Robert")));
  people[0].sayhi();
  SarVector<string> fullnames = people.get_property<string>("fullname");
  cout << "Name is: " << fullnames[0] << "\n";
  delete Sar_Dbi::dbi; // only cleanup necessary
  return 0;
};

Installation

Prerequisites

One or more of the following databases and their dev components:

Get The Source

You can download the current stable release from the releases page or use Subversion to get a development release:

svn co https://svn.butterfat.net/public/StactiveRecord/trunk StactiveRecord

Note that if you download a development release you will need current versions of the autotools installed, and you must run ./autogen.sh first before following these instructions.

Compile

Enter the StactiveRecord directory and type:

./configure

You can use the following to see additional configuration options:

./configure --help

Then:

make
su root
make install

Docs

Windows

Alberto Gili was able to compile StactiveRecord using VC++. His project files and documentation can be found at:

I do not use Windows, much less VC++, and have no idea if it works; thanks to Alberto, though. These files are released under the GPL v2.0 license as well.