Yii --Command task processing_PHP tutorial
1. Configure the components required to perform tasks
Task configuration file:/protected/config/console.php
The configuration method is similar to configuring the main file [html]
// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
// application components
// Automatically loaded model and component classes
'import'=>array(
'application.models.*',//Load all model classes under the "application/models/" folder
'application.components.*', //Load all application component classes in the "application/components/" folder
'application.extensions.*', //Load all application component classes in the "application/extensions/" folder
),
'components'=>array(
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=dbname',//Connect to the mysql database
'emulatePrepare' => true,
‘username’ => ‘root’,//MySQL database username
'password' => '123456',//MySQL database user password
'charset' => 'utf8',//MySQL database encoding
'tablePrefix' => 'zd_', //MySQL database table prefix
'enableProfiling'=>true,
'enableParamLogging'=>true,
),
//Load the Email component
'mailer' => array(
'Class' = & gt; 'application.extersions.mailer.emailer',
),
),
);
// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
// application components
// Automatically loaded model and component classes
'import'=>array(
'application.models.*',//Load all model classes in the "application/models/" folder
'application.components.*',//Load all application component classes in the "application/components/" folder
'application.extensions.*',//Load all application component classes in the "application/extensions/" folder
),
'components'=>array(
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=dbname',//Connect mysql database
'emulatePrepare' => true,
'username' => 'root',//MySQL database username
'password' => '123456',//MySQL database user password
'charset' => 'utf8',//MySQL database encoding
'tablePrefix' => 'zd_', //MySQL database table prefix
'enableProfiling'=>true,
‘enableParamLogging’=>true,
),
//Load Email component
'mailer' => array(
'class' => 'application.extensions.mailer.EMailer',
),
),
);2.Task file
Place it in the /protected/commands/ file directory and inherit the CConsoleCommand base class as a task file. The naming method is Task name+Command
For example GoCommand.php[html]
/**
* Automatically run files
*/
class GoCommand extends CConsoleCommand
{
/**
* * Infinite loop output
*/
Public function run(){
for($i=1;$i>0;$i++){
self::echoWord($i);
sleep(2);//Sleep for 2 seconds
// Jump out
If(i==500){
break;
}
}
/**
* Output hollo word
*/
Public function echoWord($i){
echo "hollo word --$in";
}
}
/**
* Automatically run files
*/
class GoCommand extends CConsoleCommand
{
* Infinite loop output
*/
public function run(){
for($i=1;$i>0;$i++){
self::echoWord($i);
Sleep(2);//Sleep for 2 seconds
//Jump out
if(i==500){
Break;
}
}
}
/**
*/
public function echoWord($i){
echo "hollo word --$in";
}
}3.Perform tasks
Open the command line tool, enter the /protected directory of the project, enter the yiic command, and a prompt will appear. The prompt list displays the task file just written [html]
E:projectappprotected>yiic
Yii command runner (based on Yii v1.1.12)
Usage: E:zeeezydprotectedyiic.php
The following commands are available:
- go
- mailqueue
- message
- migrate
- shell
- webapp
To see individual command help, use the following:
E:projectappprotected>yiic
Usage: E:zeeezydprotectedyiic.php
The following commands are available:
- mailqueue
- message
- migrate
- shell
- webapp
To see individual command help, use the following:Execute the command yiic go to achieve task processing

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Goat Simulator 3 is a game with classic simulation gameplay, allowing players to fully experience the fun of casual action simulation. The game also has many exciting special tasks. Among them, the Goat Simulator 3 Imperial Tomb task requires players to find the bell tower. Some players are not sure how to operate the three clocks at the same time. Here is the guide to the Tomb of the Tomb mission in Goat Simulator 3! The guide to the Tomb of the Tomb mission in Goat Simulator 3 is to ring the bells in order. Detailed step expansion 1. First, players need to open the map and go to Wuqiu Cemetery. 2. Then go up to the bell tower. There will be three bells inside. 3. Then, in order from largest to smallest, follow the familiarity of 222312312. 4. After completing the knocking, you can complete the mission and open the door to get the lightsaber.

1. First, we right-click the blank space of the taskbar and select the [Task Manager] option, or right-click the start logo, and then select the [Task Manager] option. 2. In the opened Task Manager interface, we click the [Services] tab on the far right. 3. In the opened [Service] tab, click the [Open Service] option below. 4. In the [Services] window that opens, right-click the [InternetConnectionSharing(ICS)] service, and then select the [Properties] option. 5. In the properties window that opens, change [Open with] to [Disabled], click [Apply] and then click [OK]. 6. Click the start logo, then click the shutdown button, select [Restart], and complete the computer restart.

Title: The working principle and configuration method of GDM in Linux systems In Linux operating systems, GDM (GNOMEDisplayManager) is a common display manager used to control graphical user interface (GUI) login and user session management. This article will introduce the working principle and configuration method of GDM, as well as provide specific code examples. 1. Working principle of GDM GDM is the display manager in the GNOME desktop environment. It is responsible for starting the X server and providing the login interface. The user enters

TikTok, as one of the most popular social media platforms at the moment, has attracted a large number of users to participate. On Douyin, there are many fan group tasks that users can complete to obtain certain rewards and benefits. So where can I find Douyin fan club tasks? 1. Where can I view Douyin fan club tasks? In order to find Douyin fan group tasks, you need to visit Douyin's personal homepage. On the homepage, you will see an option called "Fan Club." Click this option and you can browse the fan groups you have joined and related tasks. In the fan club task column, you will see various types of tasks, such as likes, comments, sharing, forwarding, etc. Each task has corresponding rewards and requirements. Generally speaking, after completing the task, you will receive a certain amount of gold coins or experience points.

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

In the process of PHP development, dealing with special characters is a common problem, especially in string processing, special characters are often escaped. Among them, converting special characters into single quotes is a relatively common requirement, because in PHP, single quotes are a common way to wrap strings. In this article, we will explain how to handle special character conversion single quotes in PHP and provide specific code examples. In PHP, special characters include but are not limited to single quotes ('), double quotes ("), backslash (), etc. In strings

Recently, many Win10 system users want to change the user profile, but they don’t know how to do it. This article will show you how to set the user profile in Win10 system! How to set up user profile in Win10 1. First, press the "Win+I" keys to open the settings interface, and click to enter the "System" settings. 2. Then, in the opened interface, click "About" on the left, then find and click "Advanced System Settings". 3. Then, in the pop-up window, switch to the "" option bar and click "User Configuration" below.

The default display behavior for components in the Angular framework is not for block-level elements. This design choice promotes encapsulation of component styles and encourages developers to consciously define how each component is displayed. By explicitly setting the CSS property display, the display of Angular components can be fully controlled to achieve the desired layout and responsiveness.
