Posted By

bendalton on 09/12/08


Tagged

database active record AIR Flex orm


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

THEPWN3R


AIR ActiveRecord is Open Source


 / Published in: ActionScript 3
 

URL: http://jacwright.com/blog/79/air-activerecord-is-open-source/

Active Record ORM implementation in ActionScript 3 for AIR's SQLite DB

  1. 1.
  2. var employee = new Employee();
  3. 2.
  4. employee.loadBy("username = ?", "bobTheBuilder");
  5. 3.
  6.  
  7. 4.
  8. // accessing tasks will autoload them from the database
  9. 5.
  10. for each (var task:Task in employee.tasks)
  11. 6.
  12. trace(task);
  13. 7.
  14.  
  15. 8.
  16. task = new Task("Call your mother");
  17. 9.
  18. employee.task.push(task);
  19. 10.
  20. employee.saveTasks();
  21. 11.
  22.  
  23. 12.
  24. employee.firstName = "Bobby";
  25. 13.
  26. employee.save();
  27. 14.
  28.  
  29. 15.
  30. var employee2:Employee = new Employee();
  31. 16.
  32. employee2.firstName = "Sue";
  33. 17.
  34. ....
  35. 18.
  36. employee2.save();
  37. 19.
  38. trace(employee2.id); // new id

Report this snippet  

You need to login to post a comment.