|
@@ -19,11 +19,8 @@ class WordPushCommand extends CConsoleCommand
|
|
|
public function actionIndex($school_id = '', $YII_ENV = 'development')
|
|
|
{
|
|
|
// 连接业务库
|
|
|
-// $pdoParam = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES "utf8";');
|
|
|
-// $businessServer = Yii::app()->params["businessDb"];
|
|
|
+ $pdoParam = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES "utf8";');
|
|
|
$databaseFields = 'database_host,database_name,database_user,database_password,school_id';
|
|
|
-// $busDsn = 'mysql:host=' . $businessServer['addr'] . ';dbname=' . Yii::app()->params["default_db"]['name'] . ';';
|
|
|
-// $busDbh = new PDO($busDsn, $businessServer['username'], $businessServer['password'], $pdoParam);
|
|
|
$busDbh = Yii::app()->businessDb;
|
|
|
// 获取所有可用的学校
|
|
|
if ($school_id) {
|
|
@@ -31,10 +28,8 @@ class WordPushCommand extends CConsoleCommand
|
|
|
} else {
|
|
|
$dataSql = "SELECT {$databaseFields} FROM `database` WHERE `school_id` IN (SELECT school_id FROM `school` WHERE `status`=0)";
|
|
|
}
|
|
|
-
|
|
|
// 找出学校的链接信息
|
|
|
- $dataObj = $busDbh->query($dataSql);
|
|
|
- $dataInfo = $dataObj->fetchAll(PDO::FETCH_ASSOC);
|
|
|
+ $dataInfo = $busDbh->createCommand($dataSql)->queryAll();
|
|
|
if (empty($dataInfo)) {
|
|
|
exit('未找到学校数据库链接信息!');
|
|
|
}
|
|
@@ -47,15 +42,13 @@ class WordPushCommand extends CConsoleCommand
|
|
|
}
|
|
|
|
|
|
$schoolIdString = implode(',', $schoolIds);
|
|
|
- $schoolObj = $busDbh->query("SELECT s.school_id,r.region_name FROM `school` s LEFT JOIN `region` r ON r.region_id = s.province_id WHERE s.`school_id` IN ({$schoolIdString})");
|
|
|
- $schoolInfo = $schoolObj->fetchAll(PDO::FETCH_ASSOC);
|
|
|
+ $schoolInfo = $busDbh->createCommand("SELECT s.school_id,r.region_name FROM `school` s LEFT JOIN `region` r ON r.region_id = s.province_id WHERE s.`school_id` IN ({$schoolIdString})")->queryAll();
|
|
|
foreach ($schoolInfo as $key => $tempProvince) {
|
|
|
$schoolProvince[$tempProvince['school_id']] = $tempProvince['region_name'];
|
|
|
}
|
|
|
|
|
|
// 获取所有学科
|
|
|
- $packSubject = array();
|
|
|
- $subjectObj = $busDbh->query('SELECT subject_id,subject_name,section FROM `subject`')->fetchAll(PDO::FETCH_ASSOC);
|
|
|
+ $subjectObj = $busDbh->createCommand('SELECT subject_id,subject_name,section FROM `subject`')->queryAll();
|
|
|
foreach($subjectObj as $tempSubject) {
|
|
|
$packSubject[$tempSubject['subject_id']]['name'] = $tempSubject['subject_name'];
|
|
|
$packSubject[$tempSubject['subject_id']]['section'] = $tempSubject['section'];
|
|
@@ -95,7 +88,7 @@ class WordPushCommand extends CConsoleCommand
|
|
|
if (empty($callbackUrl) || empty($analysisUrl)) continue;
|
|
|
echo $analysisUrl.'----'.$callbackUrl. "\n";
|
|
|
|
|
|
- if (false !== strpos($info['word_path'], 'http://')) {
|
|
|
+ if (false !== strpos($info['word_path'], 'https://') || false !== strpos($info['word_path'], 'http://')) {
|
|
|
$time = time();
|
|
|
$arr = self::getFile($info['word_path'], '/tem', $info['uploader_id'] . $time . '.docx');
|
|
|
if ($arr && file_exists($arr['save_path'])) {
|