12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\modules\car\models;
- use Yii;
- /**
- * This is the model class for table "{{%f_spc_car}}".
- *
- * @property int $id
- * @property string $card_num
- * @property int $is_spec
- * @property string $bak
- * @property string $dept
- */
- class FSpcCar extends \app\common\models\EActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%f_spc_car}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['is_spec'], 'integer'],
- [['card_num'], 'string', 'max' => 50],
- [['bak', 'dept'], 'string', 'max' => 100],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'card_num' => '车牌号码',
- 'is_spec' => '特殊车辆',
- 'bak' => '说明',
- 'dept' => '所属单位',
- ];
- }
- public function dptOptions($k=NULL)
- {
- $resultList = Yii::$app->db->createCommand("select distinct(dept) from {{%f_spc_car}}")->queryAll();
- $options = [];
- if(is_array($resultList))foreach($resultList as $result)
- {
- $options[$result['dept']] = $result['dept'];
- }
- if($k)return $options[$k];
- return $options;
- }
- }
|