maltyxx / origami
此包已被 弃用 且不再维护。未建议替代包。
CodeIgniter 3 的 Origami ORM
v1.0.3
2017-10-19 13:14 UTC
Requires
- php: >=5.3.0
- composer/installers: 1.0.*
README
Codeigniter 3 的对象关系映射
要求
- PHP 5.3.x (Composer 要求)
- CodeIgniter 3.0.x
安装
步骤 1 使用 Composer 安装
运行 composer
composer require maltyxx/origami
步骤 2 创建文件
在 /application/controllers/Origami_generator.php
中创建控制器文件。
<?php defined('BASEPATH') OR exit('No direct script access allowed'); require(APPPATH.'/third_party/origami/controllers/Origami_generator.php');
步骤 3 配置
将配置文件 ./application/third_party/origami/config/origami.php
复制到 ./application/config/origami.php
。
步骤 4 示例
模型文件位于 /application/models/User_model.php
。
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class User_model extends CI_Model { function __construct() { parent::__construct(); $this->load->add_package_path(APPPATH.'third_party/origami'); $this->load->library('origami'); $this->load->remove_package_path(APPPATH.'third_party/origami'); } public function create() { $user = new \Entity\test\user(); $user->firstname = 'John'; $user->lastname = 'Do'; $user->dateinsert = new DateTime(); $user->dateupdate = new DateTime(); $user->save(); } }