Answer the question
In order to leave comments, you need to log in
How to use the console command to access the database in Yii?
The site works in the browser and there is a connection to the database.
I create a console command to execute it via cron.
1) In the protected folder I create the file cron.php
<?php
$yiic=dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR.'yiic.php';
$config=dirname(__FILE__).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'console.php';
require_once($yiic);
<?php
class TodayCommand extends CConsoleCommand
{
public function run()
{
$note = new Note();
$note-> visible = 0;
$note->save(false);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question