<?php
// sqlobject 提供简易的 表关联操作
require_once 'db.php';
interface SqlObject {
}
abstract class TableWrapper {
static function mapping($tableClass){}
}
abstract class Table {
public $tableName;
/**
* 操作的校验规则
*
* @var array
*/
public $validateRules = null;
}
// Test case
class UserTable extends Table {
public $tableName = 'users';
}
TableWrapper::mapping('UserTable')->find();
TableWrapper::mapping('UserTable')->findAll();
TableWrapper::mapping('UserTable')->add();
TableWrapper::mapping('UserTable')->addMore();
TableWrapper::mapping('UserTable')->delete();
TableWrapper::mapping('UserTable')->deleteAll();
TableWrapper::mapping('UserTable')->createRow()->save();
TableWrapper::mapping('UserTable')->createRow()->destroy();
TableWrapper::mapping('UserTable')->createRow()->isNew();
[置顶] 近期要完成的工具类 标注下:
PHP ORM 实现与应用
最新推荐文章于 2025-10-12 03:57:33 发布
本文介绍了一种基于PHP的简单ORM实现方式,通过定义接口和抽象类来封装数据库操作,实现了包括查找、添加、删除等基本功能。此外,还展示了如何通过TableWrapper类进行表关联操作。
1120

被折叠的 条评论
为什么被折叠?



