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
一個類文件中重復(fù)可以使用as 起一個別名
5.設(shè)置布局文件
6.classname
order::classname
---表示的order的AR類的所有的屬性
更多關(guān)于Yii相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Yii框架入門及常用技巧總結(jié)》、《php優(yōu)秀開發(fā)框架總結(jié)》、《smarty模板入門基礎(chǔ)教程》、《php面向?qū)ο蟪绦蛟O(shè)計入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家基于Yii框架的PHP程序設(shè)計有所幫助。
相關(guān)文章
php下實現(xiàn)偽 url 的超簡單方法[轉(zhuǎn)]
php下實現(xiàn)偽 url 的超簡單方法[轉(zhuǎn)]...2007-09-09php使用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-07php使用Swoole實現(xiàn)毫秒級定時任務(wù)的方法
這篇文章主要介紹了php使用Swoole實現(xiàn)毫秒級定時任務(wù)的方法,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-09-09Zend Framework實現(xiàn)自定義過濾器的方法
這篇文章主要介紹了Zend Framework實現(xiàn)自定義過濾器的方法,結(jié)合實例形式分析了Zend Framework自定義過濾器的簡單定義與使用方法,需要的朋友可以參考下2016-12-12