This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list($controller, $actionID) = Yii::app()->createController('site/contact'); | |
$controller->layout = false; | |
$action = $controller->createAction($actionID); | |
ob_start(); | |
$action->runWithParams(array('id'=>1)); | |
$output = ob_get_contents(); | |
ob_end_clean(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array( | |
'class' => 'CCheckBoxColumn', | |
'checked' => 'in_array($data->user_id, ' . var_export($campaign->reviewIds, 1) . ')', | |
'value' => '$data->user_id', | |
'selectableRows' => 100, | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# What I want: | |
# A method that saves related (simple!) models. Simple models only have 1 attribute that requires user input. | |
# Second thing is that I want relations to be toggled with an "active" attribute. | |
# What I have: | |
# If I want a Many Many relation to be 'toggled', i need to make a Has Many relation to the in-between-table Model. | |
# - Public array which holds all related data that needs to be saved. | |
# The array is like this: | |
array | |
( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class foo extends CActiveRecord | |
class User extends foo | |
class Post extends foo | |
userController User Post | |
========== === === | |
{ | |
function actionThatAddsUserAndPosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class foo extends CActiveRecord | |
{ | |
public function save($runValidation=true,$attributes=null) | |
{ | |
if( Yii::app()->db->getCurrentTransaction() === null ) | |
{ | |
$transaction = Yii::app()->db->beginTransaction(); | |
$transaction->attachbehavior('modelSaveTransaction', new CBehavior); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## tr() is a custom trace function that does Yii::trace(CVarDumper::dumpAsString($user),'jlog'); | |
CONTROLLER: | |
/** | |
* Creates a new model. | |
* If creation is successful, the browser will be redirected to the 'view' page. | |
*/ | |
public function actionCreate() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VIEW: | |
$this->widget('zii.widgets.grid.CGridView', array( | |
'id'=>'incident-grid', | |
'ajaxUpdate'=>true, | |
'dataProvider'=>$model->search(), | |
'filter'=>$model, | |
'columns'=>$columns | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VIEW: | |
$this->widget('zii.widgets.grid.CGridView', array( | |
'id'=>'incident-grid', | |
'ajaxUpdate'=>true, | |
'dataProvider'=>$model->search(), | |
'filter'=>$model, | |
'columns'=>$columns | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have a CGridview, with a column that calls a function in the model. | |
$data->getActieveKanalen($data->id, '.$kanaal->id.', $row) | |
Today, I turned E_STRICT on, and I got the following PHP error. Before I never saw this, because only E_ALL was on. With only E_ALL, the code works without any problems.. | |
PHP Error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array('field1', 'unique', 'criteria'=>array( | |
'condition'=>'field2=:field2', | |
'params'=>array(':field2'=>$this->field2), | |
)), |
NewerOlder