verb
property of the URL rule.GET
request for post/123
will be processedpost/view
, and PUT
or POST
on post/123
- action post/update
. return array( 'components'=>array( 'urlManager'=>array( 'urlFormat'=>'path', 'rules'=>array( array('<controller>/view', 'pattern'=>'<controller:\w>/<id:\d+>', 'verb'=>'GET'), array('<controller>/update', 'pattern'=>'<controller:\w>/<id:\d+>', 'verb'=>'PUT, POST'), ), ), ), );
PUT
and DELETE
data using the methods CHttpRequest :: getPut () and CHttpRequest :: getDelete () . // $sql 1000 tbl_post $sql = 'SELECT * FROM tbl_post LIMIT 20'; $dependency = new CDbCacheDependency('SELECT MAX(update_time) FROM tbl_post'); $rows = Yii::app()->db->cache(1000, $dependency)->createCommand($sql)->queryAll(); // , AR $posts = Post::model()->cache(1000, $dependency)->findAll(); // query caching with relational AR $posts = Post::model()->cache(1000, $dependency)->with('author')->findAll();
class UpdateAction extends CAction { public function run($id) { // $id $_GET['id'] } }
true
: <?php $form=$this->beginWidget('CActiveForm', array( 'enableClientValidation'=>true, )); ?> <div class="row"> <?php echo $form->labelEx($model,'username'); ?> <?php echo $form->textField($model,'username'); ?> <?php echo $form->error($model,'username'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'password'); ?> <?php echo $form->passwordField($model,'password'); ?> <?php echo $form->error($model,'password'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton('Login'); ?> </div> <?php $this->endWidget(); ?>
rated
in the Post
model that accepts a minimum entry rating as a parameter,User
model as follows: $users=User::model()->findAll(array( 'with'=>array( 'posts'=>array( 'scopes'=>array( 'rated'=>5, ), ), ), ));
through
option has been added to Active Record, which allows building relationshipsMANY_MANY
, but more flexible, allowing the acquisition and use of data from class m101129_185401_create_news_table extends CDbMigration { public function safeUp() { $this->createTable('tbl_news', array( 'id' => 'pk', 'title' => 'string NOT NULL', 'content' => 'text', )); } public function safeDown() { $this->dropTable('tbl_news'); } }
Source: https://habr.com/ru/post/116416/
All Articles