SClass.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: chenye
  5. * Date: 2018/5/29
  6. * Time: 09:58
  7. * 班级表
  8. */
  9. class SClass extends MyActiveRecord
  10. {
  11. public static function model($className = __CLASS__)
  12. {
  13. return parent::model($className);
  14. }
  15. public function tableName()
  16. {
  17. return 'class';
  18. }
  19. /**
  20. * 获取班级列表
  21. * @param string $select
  22. * @param string $condition
  23. * @return array|null
  24. *
  25. */
  26. public function getClassList($select = '', $condition = '')
  27. {
  28. $criteria = new CDbCriteria();
  29. $criteria->select = $select;
  30. $criteria->addCondition($condition);
  31. $result = $this->findAll($criteria);
  32. if($result){
  33. $info = getAttributes($result);
  34. }else{
  35. $info = array();
  36. }
  37. return $info;
  38. }
  39. /**
  40. * 获取班级名称
  41. * @param $classId
  42. * @return string
  43. */
  44. public function getClassName($classId){
  45. $sql = "select class_name from class where class_id = {$classId}";
  46. return (string)$this->getCommandBuilder()->createSqlCommand($sql)->queryScalar();
  47. }
  48. public function getClassInfo($classId){
  49. $sql = "select class_name,grade,class_id from class where class_id = {$classId}";
  50. return $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
  51. }
  52. }