Yii框架函數(shù)簡單用法分析
本文實例講述了Yii框架函數(shù)簡單用法。分享給大家供大家參考,具體如下:
1.redict
return $this->redirect(['login']);
redict其實是對于以下的封裝 等同于
$response=Yii::app->response(); $response->headers->add('location','www.baidu.com');
2.save
第一個參數(shù)是執(zhí)行驗證,第二個參數(shù)是指的那個字段(空的話 就保存全部)
如果是一個兩個的話 必須知名屬性
* @param bool $runValidation whether to perform validation (calling [[validate()]]) * before saving the record. Defaults to `true`. If the validation fails, the record * will not be saved to the database and this method will return `false`. * @param array $attributeNames list of attribute names that need to be saved. Defaults to null, * meaning all attributes that are loaded from DB will be saved. * @return bool whether the saving succeeded (i.e. no validation errors occurred). */ public function save($runValidation = true, $attributeNames = null)
3.Yii前面加一個\代表的全局
4.as
一個類文件中重復可以使用as 起一個別名
5.設置布局文件
6.classname
order::classname
---表示的order的AR類的所有的屬性
更多關于Yii相關內容感興趣的讀者可查看本站專題:《Yii框架入門及常用技巧總結》、《php優(yōu)秀開發(fā)框架總結》、《smarty模板入門基礎教程》、《php面向對象程序設計入門教程》、《php字符串(string)用法總結》、《php+mysql數(shù)據庫操作入門教程》及《php常見數(shù)據庫操作技巧匯總》
希望本文所述對大家基于Yii框架的PHP程序設計有所幫助。
相關文章
php使用file_get_contents(‘php://input‘)和$_POST的區(qū)別實例對比
這篇文章主要介紹了php使用file_get_contents(‘php://input‘)和$_POST的區(qū)別實例對比,這個知識點是比較常用的,有需要的可以參考下2021-03-03laravel5創(chuàng)建service provider和facade的方法詳解
這篇文章主要介紹了laravel5創(chuàng)建service provider和facade的方法,實例分析了laravel創(chuàng)建service、provider和facade類的具體步驟與實現(xiàn)技巧,需要的朋友可以參考下2016-07-07Zend Framework實現(xiàn)自定義過濾器的方法
這篇文章主要介紹了Zend Framework實現(xiàn)自定義過濾器的方法,結合實例形式分析了Zend Framework自定義過濾器的簡單定義與使用方法,需要的朋友可以參考下2016-12-12