AIR ActiveRecord is Open Source

I wrote about an Active Record implementation for the Adobe Integrated Runtime using it’s SQLite database functionality. I put up all the code on Google Code under the name AIR Active Record. Please check it out, let me know of bugs or online/

features, or better yet, submit fixes and add-ons. If you’re interested in being an active developer on it let me know. Update: To use the ActiveRecord (sorry for the lack of documentation), you need to extend it with a class for each table you’ll use. For example, if I wanted an employee table I would create an Employee class like this:

 package { import flight.db.activeRecord.ActiveRecord; [RelatedTo(name="tasks", className="Task", multiple)] public dynamic class Employee extends ActiveRecord { public var name:String; public var position:String; public var hireDate:Date; public var salary:Number; public var created:Date; public var modified:Date; } } 
 package { import flight.db.activeRecord.ActiveRecord; [RelatedTo(name="employee", className="Employee")] public dynamic class Task extends ActiveRecord { public var employeeId:uint; public var todo:String; public var created:Date; public var modified:Date; public function Task(todo:String = null) { this.todo = todo; } } } 

In the metadata, the name is the property name which will be

how much does cialis cost at walgreenswho makes viagrapharmacy onlinecanadian pharmacy onlinepharmacy onlinecialis dosagegeneric viagra onlinethe canadian family pharmacybuying viagra onlinebuy generic viagra

auto-generated and auto-populated (when you access it) for the relation. The className is the full class path (e.g. multiple is a flag that specifies whether it’s a one-to-many relationship. You can have many-to-many relationships as well. If you aren’t creating the database yourself there is a handy-dandy feature which will do it for you off of code introspection. Many-to-many is not supported for creation this way unless you have a class for that join table and run it on that.

 var employee:Employee = new Employee(); TableCreator.updateTable(employee); 

This will create the table if it doesn’t exist, but it is also useful for updating the table if you’ve added new properties to the class. (right now it doesn’t delete columns if you remove properties) Then, you use it. You’ll need to look at the code comments, or maybe generate the AS3 docs off of it to see all you can do, but this is some of what you can do (let’s say you have an Employee class and a Task class):

 var employee = new Employee(); employee.loadBy("username = ?", "bobTheBuilder"); // accessing tasks will autoload them from the database for each (var task:Task in employee.tasks) trace(task); task = new Task("Call your mother"); employee.task.push(task); employee.saveTasks(); employee.firstName = "Bobby";; var employee2:Employee = new Employee(); employee2.firstName = "Sue"; ....; trace(; // new id 

Pretty cool stuff. Maybe someone should document it! :D Anyone interested in figuring out and documenting super-cool code, please apply!

Why Open Source

I have to admit, it took me awhile to understand why anyone would want to open source their software. I understood perfectly well why I would want to use it, but as a developer who makes money from writing software I assumed you don’t make money writing open source software, thus, you starve. I understand now how it works and will explain simply for both developers and business why open source software makes sense.