1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- /**
- * 学校安全与隐私
- * @author jiangfei
- * @date 2015-10-29 13:30:00
- * @company 上海风车教育有限公司.
- */
- class BSchoolPrivate extends BusinessActiveRecord{
- public static function model($className = __CLASS__){
- return parent::model($className);
- }
- public function tableName(){
- return "school_private";
- }
- public function getPrivate($schoolId){
- $criteria = new CDbCriteria();
- $criteria->select = 'is_private';
- $criteria->addCondition("school_id={$schoolId}");
- $result = $this->find($criteria);
- if ($result){
- return $result->is_private;
- }else{
- return 0;
- }
- }
- public function savePrivate($schoolId, $isPrivate)
- {
- $criteria = new CDbCriteria();
- $criteria->select = 'id';
- $criteria->addCondition("school_id={$schoolId}");
- $result = $this->find($criteria);
- if ($result){
- //更新
- $bool = $this->updateByPk($result->id,array('is_private'=>$isPrivate));
- if($bool!==false){
- return true;
- }else{
- return false;
- }
- }else{
- $sp = new BSchoolPrivate();
- $sp->is_private = $isPrivate;
- $sp->school_id = $schoolId;
- $bool = $sp->save();
- if($bool){
- return true;
- }else{
- return false;
- }
- }
- }
- }
|