| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace common\models;
- use Yii;
- /**
- * This is the model class for table "{{%CALC_RECORD}}".
- *
- * @property string $ID
- * @property string $PERIOD_NUM 周期
- * @property string $TEXT 日志
- * @property int $CREATED_AT 创建时间
- */
- class CalcRecord extends \common\components\ActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%CALC_RECORD}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['PERIOD_NUM', 'TEXT'], 'required'],
- [['PERIOD_NUM'], 'number'],
- [['TEXT'], 'string', 'max' => 2000],
- [['ID'], 'unique'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'ID' => 'ID',
- 'PERIOD_NUM' => '周期数',
- 'TEXT' => '日志',
- 'CREATED_AT' => '创建时间',
- ];
- }
- public static function record($periodNum, $text): bool
- {
- CalcRecord::insertOne([
- 'PERIOD_NUM' => $periodNum,
- 'TEXT' => $text,
- 'CREATED_AT' => time(),
- ]);
- return true;
- }
- }
|