Skip to content
Browse files

fixed markdown for readme

  • Loading branch information...
1 parent 25045c9 commit 9c60dec39990def86cd7dcf0c65d370e8b9954c8 @bmuller committed Jan 15, 2011
Showing with 38 additions and 37 deletions.
  1. +38 −37 README.markdown
View
75 README.markdown
@@ -4,65 +4,66 @@ StactiveRecord is a C++ library designed to make simple database use as simple a
# Installation
## Prerequisites
One or more of the following databases and their dev components:
- * libsqlite: SQLite C libs - [http://www.sqlite.org](http://www.sqlite.org)
- * mysql c libs: distributed with the mysql client program - [http://dev.mysql.com/downloads/mysql/](http://dev.mysql.com/downloads/mysql/)
- * postgres c libs: come with PostgreSQL core - [http://www.postgresql.org/download/](http://www.postgresql.org/download/)
+
+* [libsqlite](http://www.sqlite.org): SQLite C libs
+* [mysql c libs](http://dev.mysql.com/downloads/mysql/): distributed with the mysql client program
+* [postgres c libs](http://www.postgresql.org/download/): come with PostgreSQL core
## Compiling
Stable releases can be found at [http://findingscience.com/StactiveRecord/releases.html](http://findingscience.com/StactiveRecord/releases.html). Development releases can be fetched using:
- git clone git://github.com/bmuller/StactiveRecord.git
+ git clone git://github.com/bmuller/StactiveRecord.git
You'll need to have the autotools installed and run ./autogen.sh if you download the development version.
To compile and install:
- ./configure && make && sudo make install
+ ./configure && make && sudo make install
Confiuration options can be found with:
- ./configure --help
+ ./configure --help
## Testing
- export DBCONFIG=sqlite://:memory:
- make test
+ export DBCONFIG=sqlite://:memory:
+ make test
# Usage
StactiveRecord provides both typical basic ORM functionality as well as a general database agnostic interface for CRUD operations. As an example of ORM usage:
- #include <stactivrecord/stactive_record.h>
- #include <iostream>
- using namespace stactiverecord;
- using namespace std;
+ #include <stactivrecord/stactive_record.h>
+ #include <iostream>
+ using namespace stactiverecord;
+ using namespace std;
- // Initialize the DB connection
- Sar_Dbi * Sar_Dbi::dbi = Sar_Dbi::makeStorage("sqlite://:memory:");
+ // Initialize the DB connection
+ Sar_Dbi * Sar_Dbi::dbi = Sar_Dbi::makeStorage("sqlite://:memory:");
- class Person : public Record<Person> {
- public:
- SAR_INIT();
- Person() : Record<Person>() {};
- Person(int id) : Record<Person>(id) {};
- void sayhi() { cout << "Hello\n"; };
- };
- SAR_SET_CLASSNAME(Person, "Person");
+ class Person : public Record<Person> {
+ public:
+ SAR_INIT();
+ Person() : Record<Person>() {};
+ Person(int id) : Record<Person>(id) {};
+ void sayhi() { cout << "Hello\n"; };
+ };
+ SAR_SET_CLASSNAME(Person, "Person");
- int main() {
- Person bob;
- bob.set("fullname", "Robert Somethingorother");
- bob.set("age", 50);
- bob.save();
+ 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;
- };
+ 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;
+ };
Then, to compile your program (assuming you saved it in *simple.cpp*):
- g++ $(pkg-config libstactiverecord --cflags --libs) simple.cpp -o simple
+ g++ $(pkg-config libstactiverecord --cflags --libs) simple.cpp -o simple
# Documentation
API documentation can be created using the command:
- Doxygen
- firefox api/html/index.html
+ Doxygen
+ firefox api/html/index.html
Further examples (including examples with object relationships) can be found in the examples directory. Additional documentation is available online at [http://findingscience.com/StactiveRecord](http://findingscience.com/StactiveRecord)

0 comments on commit 9c60dec

Please sign in to comment.
Something went wrong with that request. Please try again.