¼ÆËã»ú¿ÆÑ§Óë¼¼Êõ1°àÉÛÁ¢Ãô ÏÂÔØ±¾ÎÄ

Ϋ ·» ѧ Ôº ±¾ ¿Æ ±Ï Òµ Éè ¼Æ

ͼ4.15 ½ÌʦÌí¼Ó

²¿·Ö´úÂëÈçÏ£º //ÀÏʦÁбí

public function teacherList(){

import('ORG.Util.Page');// µ¼Èë·ÖÒ³Àà if($this->isPost()){

$teacher_personId = $this->_param('teacher_personId'); $Where=\ $count = M('teacher')->where($Where)->count();

$Page = new Page($count,100);// ʵÀý»¯·ÖÒ³Àà ´«Èë×ܼǼÊýºÍÿҳÏÔʾµÄ¼Ç¼Êý $show = $Page->show();// ·ÖÒ³ÏÔʾÊä³ö

// ½øÐзÖÒ³Êý¾Ý²éѯ ×¢Òâlimit·½·¨µÄ²ÎÊýҪʹÓÃPageÀàµÄÊôÐÔ $list=M('teacher')->where($Where)->order('teacher_id desc')->limit($Page->firstRow.','.$Page->listRows)->select(); }else{

$count = M('teacher')->count();// ²éѯÂú×ãÒªÇóµÄ×ܼǼÊý

$Page = new Page($count,100);// ʵÀý»¯·ÖÒ³Àà ´«Èë×ܼǼÊýºÍÿҳÏÔʾµÄ¼Ç¼Êý $show = $Page->show();// ·ÖÒ³ÏÔʾÊä³ö

// ½øÐзÖÒ³Êý¾Ý²éѯ ×¢Òâlimit·½·¨µÄ²ÎÊýҪʹÓÃPageÀàµÄÊôÐÔ

30

Ϋ ·» ѧ Ôº ±¾ ¿Æ ±Ï Òµ Éè ¼Æ

$list=M('teacher')->order('teacher_id

desc')->limit($Page->firstRow.','.$Page->listRows)->select(); }

$this->assign('page',$show);// ¸³Öµ·ÖÒ³Êä³ö $this->assign(\ $this->display(); }

//Ìí¼ÓÀÏʦÕ˺Å

public function teacherAdd(){ if($this->isPost()){

$teacher_personId = $this->_param('teacher_personId'); $teacher_password = md5($this->_param('teacher_password')); $teacher_name = $this->_param('teacher_name');

$parent = M('teacher') ->where(array('teacher_parentId'=>$teacher_parentId))->find(); if(!empty($user)){

$this->error('¸ÃÀÏʦÕʺÅÒÑ´æÔÚ'); exit(); }

if(empty($teacher_personId) || empty($teacher_password)){ $this->error('Õ˺ÅÓëÃÜÂë²»ÄÜΪ¿Õ'); exit(); }

if(empty($teacher_name)){ $this->error('ÐÕÃû²»ÄÜΪ¿Õ'); exit(); }

$data=array(

'teacher_name' => $teacher_name, 'teacher_personId' => $teacher_personId, 'teacher_password' => $teacher_password, 'teacher_time' => time(), );

$id=M('teacher') ->data($data) ->add();

31

Ϋ ·» ѧ Ôº ±¾ ¿Æ ±Ï Òµ Éè ¼Æ

if($id){

$this -> success('Ìí¼Ó³É¹¦',U('teacherList')); }else{

$this->error('Ìí¼Óʧ°Ü'); } }else{

$this->display(); } }

//ÐÞ¸ÄÀÏʦÐÅÏ¢

public function teacherEdit(){

$teacher_id = $this->_param('teacher_id');

$info = M('teacher')->where(array('teacher_id'=>$teacher_id))->find(); if($this->isPost()){

$teacher_personId = $this->_param('teacher_personId'); $teacher_password = trim($this->_param('teacher_password')); $teacher_name = $this->_param('teacher_name'); if(empty($teacher_password)){

$teacher_password = $info['teacher_password']; }else{

$teacher_password = md5($teacher_password); }

$data=array(

'teacher_name' => $teacher_name, 'teacher_personId' => $teacher_personId, 'teacher_password' => $teacher_password, );

$id=M('teacher')->where(array('teacher_id'=>$teacher_id)) ->save($data); if($id !== false){

$this -> success('Ð޸ijɹ¦',U('teacherList')); }else{

$this->error('ÐÞ¸Äʧ°Ü'); }

32

Ϋ ·» ѧ Ôº ±¾ ¿Æ ±Ï Òµ Éè ¼Æ

}else{

$this->assign(\ $this->display(); } } }

4.2.8 ·ÖÀàµÄÌí¼Ó¼°ÐÞ¸Ä

¹ÜÀíÔ±¿ÉÒÔ¶ÔÐÂÎŵķÖÀà½øÐÐÌí¼ÓºÍÐ޸ģ¬Ôö¼ÓÁËÄÚÈݵĶàÑùÐÔ¡£

ͼ4.16·ÖÀàµÄÌí¼Ó

²¿·Ö´úÂëÈçÏ£º

//ÐÞ¸ÄÀ¸Ä¿

public function update(){

$id = $this->_param('id');//À¸Ä¿id if($this->isGet()){

$data=M('column')->where(array('id'=>$id))->find();

$info=M('category')->where(array('pid'=>1,'deleteFlag'=>1))->select(); $this->assign('data',$data); $this->assign('info',$info); $this->display(); }elseif($this->isPost()){

$flag=$this->_param('flag');//1ϵͳ 2ÊÖ¶¯

33