red beanphp orm presentation

Download Red beanphp orm presentation

If you can't read please download the document

Upload: chris-chubb

Post on 25-Jun-2015

1.172 views

Category:

Technology


0 download

DESCRIPTION

An overview of the RedBean ORM for PHP

TRANSCRIPT

  • 1.
    • redbeanphp.com

2. RedBean ORM

  • ORM Object Relational Model

3. The Easiest ORM 4. Simple to

  • Install

5. Use 6. Grow 7. Live with 8. Are you living in the real world?

  • Do you know your complete data model before you start a project? Does it ever change?

9. Ever heard this?

  • Just get it done!

10. We'll fix it tomorrow 11.

  • 1 include file

12. 1 connect line 13. Start coding 14. include_once('rb.php'); $book = $redbean->dispense("book"); //Make a new book $book->author = "Santa Claus"; //Give it some properties $book->title = "Secrets of Christmas"; $id = $redbean->store( $book ); //Persist it $book = $redbean->load( "book", $id ); //Find a book $books = Finder::where("book", "author = :str", array(":str"=>'Santa Claus')); $redbean->trash( $book ); //Throw it away 15. Got Code?

  • CodeMonkey like RedBean...

16. What Else?

  • When you don't want to beflexible any more and wantmore speed, ->freeze().
  • Prevents DB changes and field growing.

Hierarchies

  • R::attach($father,$daughter); R::attach($father,$son); $children = R::children( $father ); $father = R::getParent( $son ); $parent_id = $child->parent_id;

17. Write your own models

  • Auto-discovers the right classes
  • Validation

18. Data Normalization class Model_Book extends RedBean_SimpleModel {public function update() { if (!preg_match( $somePattern, $this->title )) { throw new Exception("Illegal title!"); }} } 19. Advanced Stuff

  • Plugins
  • Table Optimizer (auto date!)

20. Caching Unit of Work For Transactions 21. Framework Integration

  • Kohana

22. Zend 23. Code Igniter 24. Good/Bad/Fugly

  • Good
  • Small(227k. Doctrine is about 2 meg in 382 files)

25. Easy to understand(5 methods on one class) 26. No new languages (uses SQL for queries) Bad

  • No chaining($authors = $book->authors->order_by('author_name);)

Fugly

  • Uses PDO.(Fake withR::$db = $mydbobject;)