nkey/caribu 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nkey/caribu

最新稳定版本:v1.0.1

Composer 安装命令:

composer require nkey/caribu

包简介

Annotation based OR Mapping framework for PHP

关键字:

README 文档

README

Build Status Code Coverage Scrutinizer Code Quality Dependency Status Codacy Badge

caribu

An annotation-based PHP Object Relational Mapper

This project aims to be an object relational mapper easy to use. The main target is to support developers writing only simple attribute containing classes and store it as entities into a database.

It has support for annotations so it is very flexible.

Here is a very basic example about the usage (for sqlite):

  CREATE TABLE super_duper_content (id INTEGER PRIMARY KEY, content TEXT);
  /* SuperDuperEntity.php */
  
  /**
   * @table super_duper_content
   */
  class SuperDuperEntity extends AbstractModel
  {
    /**
     * @column id
     */
    private $sid;
    
    private $content;
    
    public function setSid($sid)
    {
      $this->sid = $sid;
    }
    
    public function getSid()
    {
      return $this->sid;
    }
    
    public function setContent($content)
    {
      $this->content = $content;
    }
    
    public function getContent()
    {
      return $this->content;
    }
  }
  /* write-data-example.php */
  
  use \Nkey\Caribu\Orm\Orm;
  
  /* First configure the ORM */
  Orm::configure(array(
    'type' => 'sqlite',
    'file' => ':memory:'
  ));
  
  // Create sqlite database table for memory storage
  // Orm::getInstance()->getConnection()->exec("CREATE TABLE super_duper_content (id INTEGER PRIMARY KEY, content TEXT)");
  
  /* Now create a new entity and persist it to database */
  $entity = new SuperDuperEntity();
  $entity->setContent("Mega important content");
  $entity->persist();
  /* read-data-example.php */
  
  /* First read the entity from database */
  $entity = SuperDuperEntity::find(array('content' => "Mega important content"));
  
  /* Display the content */
  echo $entity->getContent();

No need to write infrastructure and boilerblate code by yourself. Let the Orm do the hard work for you.

Caribu provides a convention-over-configuration behaviour by supporting annotations.

See the Wiki for more information about the capabilities and usage.

统计信息

  • 总下载量: 26
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2015-05-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固