public
Description: An objective-C implementation of ActiveRecord
Homepage: http://activerecord.lighthouseapp.com
Clone URL: git://github.com/aptiva/activerecord.git
Click here to lend your support to: activerecord and make a donation at www.pledgie.com !
name age message
file .gitattributes Fri Jul 25 13:21:00 -0700 2008 Gitignore&stuff Also fixed name of readme in th... [aptiva]
file .gitignore Thu Aug 21 04:16:33 -0700 2008 Fixed ignore entry for xcode mode files [aptiva]
directory ActiveRecord.xcodeproj/ Thu Oct 02 15:20:28 -0700 2008 Keeping up [aptiva]
file ActiveRecord_Prefix.pch Tue Aug 19 17:10:16 -0700 2008 Minor changes [aptiva]
file Doxyfile Thu Jul 24 02:40:45 -0700 2008 Importing svn repos [aptiva]
directory English.lproj/ Thu Jul 24 02:40:45 -0700 2008 Importing svn repos [aptiva]
file Info.plist Thu Jul 24 02:40:45 -0700 2008 Importing svn repos [aptiva]
file LICENSE Thu Jul 24 02:40:45 -0700 2008 Importing svn repos [aptiva]
directory MySQL Libraries/ Thu Sep 18 17:27:27 -0700 2008 minor changes [aptiva]
directory Project Templates/ Thu Sep 18 17:35:03 -0700 2008 Double checked iPhone template [aptiva]
file README.markdown Fri Aug 29 17:06:59 -0700 2008 Updated readme to reflect the new location of t... [aptiva]
directory Source/ Wed May 20 09:07:33 -0700 2009 Fixed UTF-8 Error in armysqlconnection [aptiva]
file TODO Thu Jul 24 02:40:45 -0700 2008 Importing svn repos [aptiva]
file Unit tests-Info.plist Thu Jul 24 02:40:45 -0700 2008 Importing svn repos [aptiva]
directory Unit tests/ Thu Oct 02 15:19:31 -0700 2008 Made mysql connection use 127.0.0.1 instead of ... [aptiva]
README.markdown

ActiveRecord ReadMe

About:

ActiveRecord is an insanely easy to use database framework written in objective-c It's obviously "inspired" by (copying) the infamous ActiveRecord that comes with Rails(http://rubyonrails.org) But it tries to be more versatile when it comes to working with multiple connections.

I'm not very good at writing these things so consult the docs/tutorials/whatever for more info. (scroll down!)

ActiveRecord was written by ninja kitten (http://ninjakitten.us) and is licensed with the BSD license.

Features:

  • Supported databases
  • SQLite 3
  • MySQL 5.0
  • Supported relationships
  • Has many
  • Has one
  • Has and belongs to many
  • Belongs to
  • Almost no code required

Using on iPhone:

Building for iPhone is rather simple. Step 1: Check out the latest code and rename the directory to "activerecord-read-only" * Build for mac os x This will create a directory called 'iPhone Headers' which contains all the headers you need (Add it to your project's header search path)

  • Step 2:
  • Copy the iPhone project template ("Active Record Application") /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application

  • Step 3:

  • Create a new project using the template in the same directory as your checkout

Now you should be able to use ActiveRecord just like you would on a mac (Except without MySQL support).

If you have any troubles you can check out a screencast I threw up on http://ninjakitten.us/activerecord/activerecord_iphone.mov if you still have issues, just email me and I'll try to help.

Minitutorial

To create a model there are 2 steps. 1 Create the table in your database 2 Create a model class named as the singularized version of your table name (people -> person)

Example: Let's say I created a table called 'people' with 3 columns. - id as the primary key - firstName as varchar(255) - lastName as varchar(255) Then we'd create the following class definition:

@interface Person : ARBase
@end

And to prevent the compiler from complaining when we call custom accessors we also create properties to suppress 'method missing' warnings. So the class definition will look like:

@interface Person : ARBase
    @property(readwrite, assign) NSString *firstName, *lastName
@end

and the implementation:

@implementation Person
    @dynamic firstName, lastName
@end

That's it. Now we can get people like so:

NSArray *people = [Person find:ARFindAll];

and if we want the name of the second person we could:

Person *person = [people objectAtIndex:1];
NSLog(@"%@ %@", person.firstName, person.lastName);

Contributing:

If you wish to send patches you can email them to fjolnir@gmail.com

When writing patches please keep in mind the existing coding style Here's most of it:

- (id)aMethod:(int)argument
{
  int myVar = 123;
  if(myVar != 123)
    NSLog(@"impossible!");
  else
  {
    NSLog(@"Very possible..");
    // More lines of code!
  }
}