123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- /**
- * Created by PhpStorm.
- * User: chenye
- * Date: 2018/5/29
- * Time: 09:58
- * 班级表
- */
- class SClass extends MyActiveRecord
- {
- public static function model($className = __CLASS__)
- {
- return parent::model($className);
- }
- public function tableName()
- {
- return 'class';
- }
- /**
- * 获取班级列表
- * @param string $select
- * @param string $condition
- * @return array|null
- *
- */
- public function getClassList($select = '', $condition = '')
- {
- $criteria = new CDbCriteria();
- $criteria->select = $select;
- $criteria->addCondition($condition);
- $result = $this->findAll($criteria);
- if($result){
- $info = getAttributes($result);
- }else{
- $info = array();
- }
- return $info;
- }
- /**
- * 获取班级名称
- * @param $classId
- * @return string
- */
- public function getClassName($classId){
- $sql = "select class_name from class where class_id = {$classId}";
- return (string)$this->getCommandBuilder()->createSqlCommand($sql)->queryScalar();
- }
- public function getClassInfo($classId){
- $sql = "select class_name,grade,class_id from class where class_id = {$classId}";
- return $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
- }
- }
|