Giter VIP home page Giter VIP logo

beanbase's Introduction

BeanBase

Best effort smoke testing using Travis-CI (see my travis yaml file for environment setup details): Build Status

The one purpose of creating BeanBase is to make RedBeanPHP: Powerful ORM even easier to use...Skip to wiki (API docs and manual)

A slight taste with some use cases:

  1. The user should be able to create a category, and some articles.
  2. The user should be able to assign any number of articles under a category.
  3. The user should be able to fetch all articles that belongs to the same category.

Quick Implementation:

// Mock data for articles
$art_data_1 = array(
  'title' => 'Article 1',
  'body' => 'The content of this article...'
);

$art_data_2 = array(
  'title' => 'Article 2',
  'body' => 'The content of another article...'
);

// Create the article
$art_bean_1 = RBB::create( 'article', $art_data_1 );
$art_bean_2 = RBB::create( 'article', $art_data_2 );

// Mock data for a category
$cat_data = array(
  'name' => 'Category 1'
);

// Create the category
$cat_bean = RBB::create( 'category', $cat_data );

// Establish association, we decide that the relation is
// ONE-TO-MANY, Which means one category owns many articles
// or many articles belong to one category
// RBB::associate() stores beans as well
RBB::associate( $art_bean_1, RBB::RB_BELONGS_TO, $cat_bean );
RBB::associate( $cat_bean, RBB::RB_HAS_MANY, $art_bean_2 );

// Fetch articles by given category
$articles = RBB::get_related( $cat_bean, RBB::RB_HAS_MANY, 'article' );

echo "<pre>";
var_dump( $articles ); // which will result in an array of article bean objects
echo "</pre>";

Ready? Dive in!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.