123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace Cron\Controller;
- use Common\Controller\CronController;
- class WordsController extends CronController {
- public function __construct(){
- parent::__construct();
- }
- public function index(){
- $res = M('Course')->where(array('course_flag'=>1,))->field('course_id,course_num')->select();
- foreach ($res as $row){
- $count = M('Words')->where(array('course_id'=>$row['course_id'],'is_delete'=>1))->count();
- if ($count!=$row['course_num']){
- M('Course')->where(array('course_id'=>$row['course_id']))->save(array('course_num'=>$count));
- }
- }
- }
-
- public function edit(){
- $res = M()->query("select * from t_words where words_read1 not like '%]' and words_read1 not like '[%' and words_read1!=''");
- foreach ($res as $row){
- $data['words_read1'] = '['.$row['words_read1'].']';
- M('Words')->where(['words_id'=>$row['words_id']])->save($data);
- }
- $res = M()->query("select * from t_words where words_read2 not like '%]' and words_read2 not like '[%' and words_read2!=''");
- foreach ($res as $row){
- $data['words_read2'] = '['.$row['words_read2'].']';
- M('Words')->where(['words_id'=>$row['words_id']])->save($data);
- }
- $res = M()->query("select * from t_words where words_read1 not like '%]' and words_read1!=''");
- foreach ($res as $row){
- $data['words_read1'] = '['.$row['words_read1'].']';
- M('Words')->where(['words_id'=>$row['words_id']])->save($data);
- }
-
- $res = M()->query("select * from t_words where words_read2 not like '%]' and words_read2!=''");
- foreach ($res as $row){
- $data['words_read2'] = '['.$row['words_read2'].']';
- M('Words')->where(['words_id'=>$row['words_id']])->save($data);
- }
- }
- }
|