Table of Contents
Requirement
Last ChangeLog [2015-08-22]
Command [区分大小写]
Example
Home Backend Development PHP Tutorial 一个快速构建PHP ORM类的工具:ORMBuilder

一个快速构建PHP ORM类的工具:ORMBuilder

Jun 20, 2016 pm 12:50 PM

一个快速构建PHP ORM类的工具

Requirement

  • PHP 5.4 + (PDO support)
  • Linux Shell / Windown cmd

Last ChangeLog [2015-08-22]

  • 版本调整为 v1.2.0 Beta
  • 调整生成命名逻辑,保持所有文件名/类名与驼峰命名一致
  • 增加U选项保持兼容
  • 选项L弃用
  • 调整部分处理逻辑及删除判断为冗余的代码
  • 修复其它一些已知的问题

Command [区分大小写]

PHP cli模式使用 '+', Shell模式使用 '-', 建议使用Shell模式

  • fModel Class保存路径, 默认保存在gorm.php相应目录下的BuildResult文件夹下
  • eModel Class父类 (未开启命名空间,'\' 以 '_' 代替)
  • iModel Class类所需接口类 (未开启命名空间,'\' 以 '_' 代替)
  • xModel Class文件后缀名, 默认 php
  • lModel Class文件名/类名是否保留下划线, 默认 false
  • LModel Class方法名是否保留下划线, 默认 true [弃用]
  • mModel Class命名类型, 默认 1,1. %sModel 2. Model%s 3.%s_Model 4. Model_%s
  • NModel Class的命名空间,默认 \
  • FModel Class能支持写final关键字, 默认 false
  • U文件名/类名所有 _ 分隔单词首字母大写,否则仅第一单词首字母大写, 默认 true
  • o是否开启命名空间, 默认 true
  • d从Config中读取的数据库配置,默认 false
  • T设置N个空格替代一个TAB,为0时将以TAB出现,不替换, 默认 4
  • u连接mysql用户名,使用此项 +d 将失效
  • p连接mysql密码,使用此项 +d 将失效, 不建议直接在命令行输入密码
  • h连接mysql主机, 默认 127.0.0.1
  • P连接mysql主机端口, 默认 3306
  • n连接mysql数据库名
  • O数据库驱动选项处理, 多个时用 ',' 分隔
  • t指定Build的表名,多个时用 ',' 分隔
  • H显示帮助

Example

  • 使用Shell模式

sudo ln -s /home/www/OrmBuild/gorm /usr/bin/gorm
Copy after login

gorm -f "/home/gsinhi/models" -e "\Base\Model\AbstractModel" -u root -p -n test_orm
Copy after login

  • 指定保存路径

php -f gorm.php +f /home/gsinhi/testOrm
Copy after login

  • 指定数据库

php -f gorm.php +f /home/gsinhi/testOrm +u test +p +n test_orm
Copy after login

  • 关闭命名空间

php -f gorm.php +f /home/gsinhi/testOrm +o false
Copy after login

  • 示例配置 Config/Db.php
namespace Config;class Db extends \Config\ConfigAbstract {    public function init() {        return array(            'host'     => '127.0.0.1',            'dbname'   => 'test',            'username' => 'test',            'passwd'   => 'test',            'port'     => '3306',            'options'  => array("SET NAMES 'utf8'")        );    }}
Copy after login

项目主页:http://www.open-open.com/lib/view/home/1440401020497

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

See all articles