triplei / c5_base_model
与数据库交互的基础模型类
1.0.1
2017-02-20 20:53 UTC
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2024-09-16 07:38:35 UTC
README
为与concrete5 7+版本中的数据库记录交互提供一些有用功能的基础模型
基本用法
use TripleI\C5BaseModel\BaseModel class Widget extends BaseModel { /** * @var string * @Column(type="string", nullable=true) */ protected $name; /** * @var string * @Column(type="text", nullable=true) */ protected $description; } $widget = new Widget(); $widget->name = 'testing'; $widget->save(); $widget2 = new Widget(); $widget->setData( [ 'name' => 'widget name', 'description' => 'description here' ] ); $widget->save(); $allWidgets = Widget::getAll(); $oddWidgets = Widget::loadByIDs([1, 3, 5]); $singleWidget = Widget::getByID(1); $singleWidget->destroy();