intelligenia/lulo 问题修复 & 功能扩展

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

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

intelligenia/lulo

Composer 安装命令:

composer require intelligenia/lulo

包简介

A minimal ORM for PHP inspired by Django

README 文档

README

A minimal ORM for PHP inspired by Django.

What's this?

This is a small and easy to use ORM based on Django's ORM API for PHP.

Requirements

PHP 5.4 and dependencies installed by composer (AdoDB and Twig template system).

Installation

lulo has been uploaded to packagist.org can be easilly installed with composer:

composer require intelligenia/lulo

Documentation

Local configuration

Create a configuration.local.php in your web server with the structure defined in configuration.local.example.php.

This file must contain access credential to your database as seen in the example:

function get_db_settings(){
    $db_settings = [
        "server" => "<DB SERVER>",
        "user" => "<DB USER>",
        "password" => "<DB PASSWORD>",
        "database" => "<DATABASE>"
    ];
    return $db_settings;
}

This local configuration file will be loaded automatically from configuration.php and will be used to access database.

API

Extended documents:

Examples

There is a test module gives you several examples of using Lulo and its query system.

/**
 * Example user class for a social-network-like system.
 * @author Diego J. Romero López at intelligenia.
 * */
class User extends \lulo\models\LuloModel{
	
	/** Model table */
	const TABLE_NAME = "user";
	
	/** Class name*/
	const CLASS_NAME = __CLASS__;
	
	/**
	 * Metainformation of the class
	 * */
	public static $META = [
		// Description of the model
		"model_description" => "Test user",
		// Verbose name
		"verbose_name" => "test user",
		// Verbose name (plural)
		"verbose_name_plural" => "test users",
		// Gender of the verbose name
		"gender" => "m",
		// Order in lists (["field1"=>"ASC|DESC", "field2"=>"ASC|DESC", ...])
		"order" => ["username"=>"ASC"]
	];
	
	/**
	 * Model attributes
	 * */
	protected static $ATTRIBUTES = [
		// Primary key
		"stack"=>["type"=>"string", "default"=>TEST_STACK, "verbose_name"=>"User dependant stack", "auto"=>true],
		"id" => ["type"=>"int", "verbose_name"=>"Identificador único del usuario", "auto"=>true],
		
        	// Proper user fields
		"first_name" => ["type"=>"string", "verbose_name"=>"Name", "access"=>"rw"],
		"last_name" => ["type"=>"string", "verbose_name"=>"Family name"],
		"email" => ["type"=>"string", "subtype"=>"email", "verbose_name"=>"E-Mail"],
		"phone" => ["type"=>"string", "subtype"=>"phone", "verbose_name"=>"User telepohone number", "null"=>true, "default"=>null],
		"username" => ["type"=>"string", "subtype"=>"username", "verbose_name"=>"Username"],
		"sha1_password" => ["type"=>"string", "verbose_name"=>"Password"],
		
        	// Photograph of the user. Stored as a blob in database
		"main_photo" => ["type"=>"blob", "verbose_name"=>"User photo", "null"=>true, "default"=>null],
		"main_photo_mimetype" => ["type"=>"string", "verbose_name"=>"Mimetype of main_photo", "default" =>"application/octet-stream"],
		"main_photo_filename" => ["type"=>"string", "verbose_name"=>"Filename of main_photo", "null"=>true, "default"=>null],
		
        	// Datetime fields
		"last_update_datetime" => ["type"=>"string", "subtype"=>"datetime", "verbose_name"=>"Last update of this object", "auto"=>true],
		"creation_datetime" => ["type"=>"string", "subtype"=>"datetime", "verbose_name"=>"Creation datetime of this object", "auto"=>true],
	];
	
	
	/** Primary key */
	protected static $PK_ATTRIBUTES = ["stack", "id"];
	
	
	/**
	 * Related models.
	 * */
	protected static $RELATED_MODELS = ["Tag", "Photo", "Post"];
	
	
	/** Relationships */
	protected static $RELATIONSHIPS = [
	
	];
}
User::init();

Extending Lulo

Adding new DBMS SQL templates

Add a new folder in sql_templates with the name that will identify your DBMS (mssql2012, for example).

Overwrite the queries you need. Lulo template system will first load the templates you specify here and if it doesn't find the template, it will try to load it from the _default folder.

TODO

  • Allow models to dynamically change of table. It can be done by reimplementing getTableName method.
  • End translation of code to English.
  • Translate documents to English.
  • Reimplement Collection to use RecordSet.
  • Script for table creation from model. Manager class in management namespace allows creation and deletion of model tables.
  • Migrations.

License

MIT License.

Authors

  • Lulo and Lulo query created by the team leader and main developer of this project: Diego J. Romero López at intelligenia (diegoREMOVETHIS@REMOVETHISintelligenia.com)
  • DB abstraction layer created by several members of intelligenia team. Reviewed and extended by Gerardo Fernandez Rodríguez.
  • QueryResult was done with Gerardo Fernandez Rodríguez.
  • Several bugfixes and tests in MSSQL done by Francisco Morales.
  • Minor translation fixes done by Brian Holsters

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 5
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固