Yii 1.0 Cheatsheet

1
Yii API 1.0.8 hp://www.yiiframework.com CHtml CHtml is a stac class that provides a collecon of helper methods for creang HTML views. View API for more informaon and oponal method parameters) Stac Methods For CAcveRecords: acveCheckbox($m, $a); acveCheckboxList($m, $a, $data); acveDropDownList($m, $a, $data); acveFileField($m, $a); acveHiddenField($m, $a); acveId($m, $a); acveLabel($m, $a); acveLabelEx($m, $a); acveListBox($m, $a, $data); acvePasswordField($m, $a); acveRadioBuon($m, $a); acveRadioBuonList($m, $a, $data); acveTextArea($m, $a); acveTextField($m, $a); CFormModel Properes aributes, errors, safeAributeNames, scenario, validators Public Methods Events addError($a, $error); aſterValidate($scenario); aributeLabels(); beforeValidate($scenario); hasErrors($a); rules(); validate($s='', $a=NULL); onAſterValidate($e); onBeforeValidate($e); CDbConnecon Properes acve, autoCommit, autoConnect, charset, commandBuilder, conneconStatus, conneconString, currentTransacon, lastInsertId, password, schema, schemaCachingDuraon, meout, username For CForm checkbox($n, $v); checkboxList($n, $v, $data); dropDownList($n, $c, $data); fileField($n, $v); hiddenField($n, $v); label($n, $v); listBox($n, $v, $data); passwordField($n, $v); radioBuon($n, $c); radioBuonList($n, $m, $data); textArea($n, $v); textField($n, $v); Yii (extends YiiBase) Stac Methods app() /*gets the applicaon instance */ t($category, $message, $params=array ( ), $source=NULL, $language=NULL); import(string $alias, boolean $forceInclude=false); log($msg, $level='info', $category='applicaon'); CController (extends CBaseController) Properes acon, defaultAcon, id, layout, module, pageTitle Methods acons(); /*list of external acons*/ beginClip($id, $properes=array ( )); endClip($idclip=’’); beginWidget($className, $properes=array ( )); endWidget(string $id=''); missingAcon(string $aconID); redirect($url, $terminate=true, $statusCode=302); refresh($terminate=true,$anchor=''); render($view, $data=NULL, $return=false); renderParal($v, $d=NULL,$r=false, $processOutput=false); widget( $className, $properes=array ( )); CWebApplicaon (extends CApplicaon) Core applicaon components errorHandler, securityManager, statePersister, cache, messages, coreMessages Properes cache, charset, components, db, language, locale, name, modules, securityManager, sourceLanguage Methods getNumberFormaer(); getDateFormaer(); CWidget (extends CBaseController) Properes controller, id, owner, viewPath Methods init(); run(); render($view, $data=NULL, $return=false); Public Methods beginTransacon(); createCommand($sql); open(); close(); init(); quoteColumnName($name); quoteTableName($name); quoteValue($name); CHpRequest Properes baseUrl, browser, cookies, hostInfo, isAjaxRequest, isPostRequest, isSecureConnecon, pathInfo, preferredLanguage, queryString, requestUri, serverName, serverPort, url, urlReferrer, userAgent, userHost, userHostAddress Methods sendFile($fn, $c, $mime=NULL, $t=true); CAcveRecord Properes aributes, errors, isNewRecord, primaryKey, scenario Stac Methods model($className='CAcveRecord'); Public Methods Events count($c=’’, $p=array ( )); delete(); deleteAll($c='', $p=array ( )); find($c='', $p=array ( )); findAll($c='', $p=array ( )); findBySql($sql, $p=array ( )); hasErrors($a); update($a=NULL); updateAll($a, $c='', $p=array ( )); updateByPk($pk, $a, $c='', $p=array ( )); validate(); onAſterDelete($e); onAſterInsert($e); onAſterSave($e); onAſterValidate($e); onBeforeDelete($e); onBeforeSave($e); onBeforeValidate($e); CDbCommand Properes connecon, text Public Methods bindParam($n, $v, $dt=NULL, $length=NULL); bindValue($n, $v, $dataType=NULL); execute(); query(); queryAll($fetchAssociave=true); queryColumn(); queryRow($fetchAssociave=true); queryScalar();

Transcript of Yii 1.0 Cheatsheet

Page 1: Yii 1.0 Cheatsheet

Yii API 1.0.8http://www.yiiframework.com

CHtmlCHtml is a static class that provides a collection of helper methods for creating HTML views. View API for more information and optional method parameters)

Static MethodsFor CActiveRecords:activeCheckbox($m, $a);activeCheckboxList($m, $a, $data);activeDropDownList($m, $a, $data);activeFileField($m, $a);activeHiddenField($m, $a);activeId($m, $a);activeLabel($m, $a);activeLabelEx($m, $a);activeListBox($m, $a, $data);activePasswordField($m, $a);activeRadioButton($m, $a);activeRadioButtonList($m, $a, $data);activeTextArea($m, $a);activeTextField($m, $a);

CFormModelPropertiesattributes, errors, safeAttributeNames, scenario, validators

Public Methods EventsaddError($a, $error);afterValidate($scenario);attributeLabels();beforeValidate($scenario);hasErrors($a);rules();validate($s='', $a=NULL);

onAfterValidate($e);onBeforeValidate($e);

CDbConnectionPropertiesactive, autoCommit, autoConnect, charset, commandBuilder,connectionStatus, connectionString, currentTransaction, lastInsertId,password, schema, schemaCachingDuration, timeout, username

For CFormcheckbox($n, $v);checkboxList($n, $v, $data);dropDownList($n, $c, $data);fileField($n, $v);hiddenField($n, $v);label($n, $v);listBox($n, $v, $data);passwordField($n, $v);radioButton($n, $c);radioButtonList($n, $m, $data);textArea($n, $v);textField($n, $v);

Yii (extends YiiBase)

Static Methodsapp() /*gets the application instance */t($category, $message, $params=array ( ), $source=NULL, $language=NULL);import(string $alias, boolean $forceInclude=false);log($msg, $level='info', $category='application');

CController (extends CBaseController)

Propertiesaction, defaultAction, id, layout, module, pageTitle

Methodsactions(); /*list of external actions*/beginClip($id, $properties=array ( ));endClip($idclip=’’);beginWidget($className, $properties=array ( )); endWidget(string $id='');missingAction(string $actionID);redirect($url, $terminate=true, $statusCode=302);refresh($terminate=true,$anchor='');render($view, $data=NULL, $return=false);renderPartial($v, $d=NULL,$r=false, $processOutput=false);widget( $className, $properties=array ( ));

CWebApplication (extends CApplication)

Core application componentserrorHandler, securityManager, statePersister,cache, messages, coreMessagesPropertiescache, charset, components, db, language, locale, name, modules, securityManager, sourceLanguage

MethodsgetNumberFormatter(); getDateFormatter();

CWidget (extends CBaseController)

Propertiescontroller, id, owner, viewPathMethodsinit(); run(); render($view, $data=NULL, $return=false);

Public MethodsbeginTransaction();createCommand($sql);open(); close();init();

quoteColumnName($name);quoteTableName($name);quoteValue($name);

CHttpRequestPropertiesbaseUrl, browser, cookies, hostInfo, isAjaxRequest,isPostRequest, isSecureConnection, pathInfo,preferredLanguage, queryString, requestUri,serverName, serverPort, url, urlReferrer, userAgent,userHost, userHostAddressMethodssendFile($fn, $c, $mime=NULL, $t=true);

CActiveRecordPropertiesattributes, errors, isNewRecord, primaryKey, scenario

Static Methodsmodel($className='CActiveRecord');

Public Methods Eventscount($c=’’, $p=array ( ));delete();deleteAll($c='', $p=array ( ));find($c='', $p=array ( ));findAll($c='', $p=array ( ));findBySql($sql, $p=array ( ));hasErrors($a);update($a=NULL);updateAll($a, $c='', $p=array ( ));updateByPk($pk, $a, $c='', $p=array ( ));validate();

onAfterDelete($e);onAfterInsert($e);onAfterSave($e);onAfterValidate($e);onBeforeDelete($e);onBeforeSave($e);onBeforeValidate($e);

CDbCommandPropertiesconnection, text

Public MethodsbindParam($n, $v, $dt=NULL, $length=NULL);bindValue($n, $v, $dataType=NULL);execute();query();queryAll($fetchAssociative=true);queryColumn();queryRow($fetchAssociative=true);queryScalar();