[英]yii2 cron giving error of “PDO not found”
I am running application well in yii2. 我在yii2中很好地运行了应用程序。 I created a command controller /commands/TestController
我创建了一个命令控制器/ commands / TestController
<?php
namespace app\commands;
use app\models\UserProfile;
use yii\console\Controller;
use app\controllers\AppController;
/**
* Test controller
*/
class TestController extends Controller
{
public function actionIndex()
{
echo "cron service running";
}
public function actionSendBirthdaySms()
{
$userProfile = UserProfile::find()
->where('MONTH(dob) = MONTH(DATE(NOW()))')
->andWhere('DAY(dob) = DAY(NOW()) ')
->with('user')
->asArray()
->all();
foreach($userProfile as $item){
$birthdayMessage = "Happy Birthday " . $item['user']['username'];
//to send sms
$this->_send_cron_sms($item['mobile'], $birthdayMessage);
}
}
I have two functions here. 我在这里有两个功能。 When I call
php /home/user/public_html/yii test/index
it gives the correct output with command line and cron both. 当我调用
php /home/user/public_html/yii test/index
它使用命令行和cron都给出了正确的输出。
But when I am running php /home/user/public_html/yii test/send-birthday-sms
, it runs OK with command line in ssh environment and I am receiving the SMS. 但是,当我运行
php /home/user/public_html/yii test/send-birthday-sms
,它在ssh环境中通过命令行运行正常,并且正在接收SMS。 But giving error in cron. 但是给cron错误。 Here is what I received in email:
这是我在电子邮件中收到的:
Status: 500 Internal Server Error
X-Powered-By: PHP/5.4.39
Content-type: text/html
PHP Fatal Error 'yii\base\ErrorException' with message 'Class 'PDO' not found'
in /home/user/public_html/vendor/yiisoft/yii2/db/Connection.php:609
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}
I also tried query builder but it also did not helped me. 我也尝试过查询生成器,但它也没有帮助我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.