pxniu/study

一个测试composer项目

维护者

详细信息

github.com/pxniu/study

源代码

问题

安装: 3

依赖: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 0

公开问题: 0

类型:项目

dev-master 2019-05-04 08:00 UTC

This package is auto-updated.

Last update: 2024-09-04 19:48:41 UTC


README

#php框架

使用方法

1. Sql操作升级 采用方法注解实现 如:

@Select(sql = "select * from user where username = {username}")

@Update(sql = "update user set price = price + {price} where id = {id}")

@Insert(sql = "insert into user (username, password, age, height, price, addtime) values ({username}, {password}, {age}, {height}, {price}, now())")

@Delete(sql = "delete from user where id = {id}")

@SelectOne(sql = "select * from user where id = {id}")

@Update(sql = "update user set username = {username} where id = {id}")

参数通过{}注入

2. 事务升级 采用方法注解实现 如

/**
 * @Transactional
 * 事物service
 */
function updateUser()
{

}

3. 数据操作注入升级 如

class Index {
    /**
     * @Autowired(class = "\hyweb\service\Home\impl\UserServiceImpl")
     */
    private $service;

    /**
     * @Autowired(class = "\hyweb\service\Home\impl\PayServiceImpl")
     */
    private $payService;

    public function index() {
        echo Config::get("db.master", "host");
        p($this->payService->getAll());
    }
}

4. 数据判断注入 如

/**
 * @Select(sql = "select * from role <if test='name != null'>where name like %{name}%</if> order by addtime desc limit {start}, {limit}")
 */
public function getAllByExcemples() {

}

5. 数据循环注入 如

/**
 * @Insert(sql = "
    insert into roles (roleId, permissionId) values
      <foreach collection='list' item='r' separator=",">
        ({roleId}, #id#})
      </foreach>
 ")
 */
public function adds() {

}