Red beanphp orm presentation

1,398 views
1,274 views

Published on

An overview of the RedBean ORM for PHP

Published in: Technology
1 Comment
1 Like
Statistics
Notes
  • I was there. Chris did a good presentation. Thanks Chris!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
1,398
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
8
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Red beanphp orm presentation

  1. 1. <ul>redbeanphp.com </ul>
  2. 2. RedBean ORM <ul><li>ORM – Object Relational Model
  3. 3. “The Easiest ORM”
  4. 4. Simple to </li><ul><li>Install
  5. 5. Use
  6. 6. Grow
  7. 7. Live with </li></ul></ul>
  8. 8. Are you living in the real world? <ul><li>Do you know your complete data model before you start a project? Does it ever change?
  9. 9. Ever heard this? </li><ul><li>“Just get it done!”
  10. 10. “We'll fix it tomorrow” </li></ul></ul>
  11. 11. <ul><li>1 include file
  12. 12. 1 connect line
  13. 13. Start coding
  14. 14. include_once('rb.php'); $book = $redbean->dispense(&quot;book&quot;); //Make a new book $book->author = &quot;Santa Claus&quot;; //Give it some properties $book->title = &quot;Secrets of Christmas&quot;; $id = $redbean->store( $book ); //Persist it $book = $redbean->load( &quot;book&quot;, $id ); //Find a book $books = Finder::where(&quot;book&quot;, &quot;author = :str&quot;, array(&quot;:str&quot;=>'Santa Claus')); $redbean->trash( $book ); //Throw it away </li></ul>
  15. 15. Got Code? <ul><li>CodeMonkey like RedBean... </li></ul>
  16. 16. What Else? <ul><li>When you don't want to be flexible any more and want more speed, ->freeze(). </li><ul><li>Prevents DB changes and field growing. </li></ul><li>Hierarchies </li><ul><li>R::attach($father,$daughter); R::attach($father,$son); $children = R::children( $father ); $father = R::getParent( $son ); $parent_id = $child->parent_id; </li></ul></ul>
  17. 17. Write your own models <ul><li>Auto-discovers the right classes </li><ul><li>Validation
  18. 18. Data Normalization </li></ul><li>class Model_Book extends RedBean_SimpleModel { public function update() { if (!preg_match( $somePattern, $this->title )) { throw new Exception(&quot;Illegal title!&quot;); } } } </li></ul>
  19. 19. Advanced Stuff <ul><li>Plugins </li><ul><li>Table Optimizer (auto date!)
  20. 20. Caching </li></ul><li>Unit of Work – For Transactions
  21. 21. Framework Integration </li><ul><li>Kohana
  22. 22. Zend
  23. 23. Code Igniter </li></ul></ul>
  24. 24. Good/Bad/Fugly <ul><li>Good </li><ul><li>Small (227k. Doctrine is about 2 meg in 382 files)
  25. 25. Easy to understand (5 methods on one class)
  26. 26. No new languages (uses SQL for queries) </li></ul><li>Bad </li><ul><li>No chaining ($authors = $book->authors->order_by('author_name);) </li></ul><li>Fugly </li><ul><li>Uses PDO. (Fake with R::$db = $mydbobject; ) </li></ul></ul>

×