sena/nogal.se
Composer 安装命令:
composer require sena/nogal.se
包简介
Nogal (Student Edition) - This is an ORM implementation in PHP7 based on DAO to be used in the learning environments of the National Learning Service - SENA in Colombia.
关键字:
README 文档
README
It is a tiny implementation of the PHP7 ORM programming model based on DAO (Data Access Object) for use in the learning environments of the National Learning Service - SENA in Colombia.
Installation
For you to be able to use Nogal SE in your project, you must have the Composer tool installed.
composer require sena/nogal.se
Estructura del modelo
Nogal (Edición Estudiante) propone la siguiente estructura.
+-------------------- | model/ |-- base/ |---- UserBase.php |-- User.php +--------------------
Para poder explicar lo anterior debemos partir de que usaremos la siguiente estructura SQL para la tabla User.
CREATE TABLE DbUser ( Id int, Nick varchar(20), Password varchar(32), Actived boolean DEFAULT true, Created_at timestamp DEFAULT NOW() );
Archivo User.php
El siguiente código sería entonces el contenido del archivo User.php
<?php namespace MyApp\model; use MyApp\model\base\UserBase; class User extends UserBase { }
En estos archivos se ubicaría la lógica del negocio que tenga que ver con la tabla User, por ejemplo: necesito consultar el id de un usuario.
<?php namespace MyApp\model; use MyApp\model\base\UserBase; class User extends UserBase { public function SearchIdByUser() { $sql = 'SELECT Id FROM DbUser WHERE Nick = :nick'; $this->SetDbParam(':nick', $this->getNick(), \PDO::PARAM_STR); $data = $this->Query($sql); if (count($data) > 0) { return $data; } else { return false; } } }
Archivo UserBase.php
Este archivo contiene la estructura base de la tabla User y podemos expresarla de la siguiente forma:
统计信息
- 总下载量: 83
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-05