Skip to content
A C++ Implementation of the Active Record Pattern
C C++ Shell Ruby
Find file
Latest commit b510081 Oct 12, 2015 @joeyates Set up Travis CI
Failed to load latest commit information.
doc Updated docs to reflect API changes Sep 11, 2011
examples Postgresql support Oct 11, 2015
include Include postgresql server headers in project Oct 12, 2015
profiling Profile ActiveRecord or straight SQLite according to a define May 1, 2012
src Postgresql support Oct 11, 2015
test Access test env directly Oct 12, 2015
.gitignore Postgresql support Oct 11, 2015
.travis.yml Set up Travis CI Oct 12, 2015
AUTHORS Using Rake::Cpp Aug 9, 2010
COPYING Using Rake::Cpp Aug 9, 2010
ChangeLog Using Rake::Cpp Aug 9, 2010
DEVELOPMENT.md Improve autoconf maintenance Oct 12, 2015
Gemfile Improve autoconf maintenance Oct 12, 2015
INSTALL Improve autoconf maintenance Oct 12, 2015
INSTALL.md Install makedepend Oct 7, 2015
Makefile.am Access test env directly Oct 12, 2015
Makefile.in Access test env directly Oct 12, 2015
NEWS Using Rake::Cpp Aug 9, 2010
README Include configure requirements Aug 13, 2012
README.md Set up Travis CI Oct 12, 2015
Rakefile Set up Travis CI Oct 12, 2015
VERSION Missing files for autoconf process Aug 9, 2012
aclocal.m4 Improve autoconf maintenance Oct 12, 2015
compile Improve autoconf maintenance Oct 12, 2015
config.h.in Include configure requirements Aug 13, 2012
configure Improve autoconf maintenance Oct 12, 2015
configure.ac Include configure-based build files May 9, 2012
depcomp Include configure requirements Aug 13, 2012
install-sh Include configure requirements Aug 13, 2012
missing Set up Travis CI Oct 12, 2015

README.md

Build Status

ActiveRecord - a C++ implementation of the Active Record pattern.

Databases supported:

  • PostgreSQL
  • SQLite

Installation

See the file INSTALL.md.

Quick Start Guide

Here's a Hello World! example, that saves a record to the database, and retrieves it:

#include <active_record/type.h>
#include <active_record/base.h>
#include <active_record/connection.h>
#include <active_record/query.h>
#include <iostream>

using namespace ActiveRecord;

class Greeting: public ActiveRecord::Base< Greeting > {
 public:
  AR_CONSTRUCTORS( Greeting )
  static Table table( Connection * connection ) {
    Table td( connection, "greetings" );
    td.fields() = fields
                  ( "salute",   ActiveRecord::text )
                  ( "thing",    ActiveRecord::text )
                  ( "language", ActiveRecord::text );
    return td;
  }
};

AR_DECLARE( Greeting )

int main( int argc, const char *argv[] ) {
  Connection connection;
  connection.connect( options
                      ( "adapter", "sqlite" )
                      ( "database", "greetings.sqlite3" ) );
  Greeting::setup( &connection );
  connection.update_database();
  Greeting greeting( attributes
                  ( "salute", "Hello" )
                  ( "thing", "World" )
                  ( "language", "English" ) );
  greeting.save();

  Greeting greeting1( 1 );
  cout << "In " << greeting1[ "language" ] << " you say:" << endl;
  cout << "'" << greeting1[ "salute" ] << " " << greeting1[ "thing" ] << "!'" << endl;

  return 0;
}

Development and Tests

See the file DEVELOPMENT.md.

Other information

  • Usage
    • See the examples directory
  • Documentation
    • See the doc directory
Something went wrong with that request. Please try again.