我使用crontab像:
00 */1 * * * wget http://www.test.com/cron/archieve
Run Code Online (Sandbox Code Playgroud)
我想知道在> /dev/null 2>&1命令的最后使用的差异,以及它是否推荐.
我在 Users.php 模型中使用行为(DateTimeI18NBehavior),但特别是在控制器(ApiController.php)中我想禁用它。
模型 - Users.php:
public function behaviors()
{
return array(
'datetimeI18NBehavior'=>array(
'class' => 'ext.DateTimeI18NBehavior',
),
);
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以通过以下方式禁用它:
$model->disableBehavior('datetimeI18NBehavior');
Run Code Online (Sandbox Code Playgroud)
但是如何禁用整个控制器?
如何CActiveDataProvider直接获取数据,不使用CGridView?
Controller.php这样
public function actionList($id)
{
$criteria = new CDbCriteria;
$dataProvider=new CActiveDataProvider('Events', array(
'criteria' => $criteria
));
$this->render('list',array(
'dataProvider'=>$dataProvider,
));
}
Run Code Online (Sandbox Code Playgroud)
View.php:
<?php echo $dataProvider->name; ?> // Return Error
Run Code Online (Sandbox Code Playgroud) 使用Yii Framework,如何在Controller中访问模型常量?
Model.php
...
const STATUS_ACTIVE=1;
...
Run Code Online (Sandbox Code Playgroud)
Controller.php这样
...
$criteria->condition = 'status='.self::STATUS_ACTIVE;
...
Run Code Online (Sandbox Code Playgroud)
错误:
Fatal error: Undefined class constant 'STATUS_ACTIVE' in ... on line X
Run Code Online (Sandbox Code Playgroud) 什么是在Yii Framework中使用BETWEEN的正确方法?
码:
...
$criteria = new CDbCriteria;
$criteria->condition = 'datetime BETWEEN '.$datetimemin.' AND '.$datetimemax;
$user = Users::model()->find($criteria);
...
Run Code Online (Sandbox Code Playgroud)
错误:
SQL: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '07:10:10 AND 2011-10-10 13:10:10)' at line 1.
Run Code Online (Sandbox Code Playgroud) 什么是Yii::app()->user->id用作$id函数参数的正确方法?
码:
public function actionUpdate($id=Yii::app()->user->id)
Run Code Online (Sandbox Code Playgroud)
错误:
Parse error: syntax error, unexpected '(', expecting ')' in .../UserController.php on line 1
Run Code Online (Sandbox Code Playgroud) 我怎么得到的Entry 1?
_contentData数组:
(
{
id = 1;
name = "Entry 1";
},
{
id = 2;
name = "Entry 2";
},
)
Run Code Online (Sandbox Code Playgroud)
码:
NSLog(@"%@", [_contentData objectAtIndex:0]);
{
id = 1;
name = "Entry 1";
}
Run Code Online (Sandbox Code Playgroud)
码:
[_contentData objectAtIndex:0] objectAtIndex:0])
Error: Crash App
Run Code Online (Sandbox Code Playgroud)