本文整理匯總了PHP中I18n::fetch方法的典型用法代碼示例。如果您正苦於以下問題:PHP I18n::fetch方法的具體用法?PHP I18n::fetch怎麽用?PHP I18n::fetch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類I18n
的用法示例。
在下文中一共展示了I18n::fetch方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionEdit
public function actionEdit()
{
$message = "";
$lang = CatLang::fetchAll();
if (!empty($_POST["trans"])) {
for ($n = 0; $n < sizeof($lang); $n++) {
$trans = $_POST["trans"][$n];
if ($trans["id"] > 0 || $trans["translation"]) {
if ($trans["id"] > 0) {
$model = I18nTranslate::fetch($trans->id);
} else {
$model = new I18nTranslate();
}
$model->setAttributesFromArray($trans);
$model->i18n_id = $this->id;
if (!$model->save()) {
print_r($model->getErrors());
}
}
}
}
$list = array();
if (!empty($this->id)) {
$item = I18n::fetch($this->id);
$list = I18nTranslate::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("i18n_id=:id")->setParams(array(":id" => $item->id))->setLimit(-1)->setCache(0));
} else {
$item = new I18n();
}
$this->render('edit', array('form' => $item, 'list' => $list, 'lang' => $lang, 'message' => $message));
}
示例2: actionDelete
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin' page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete()
{
if ($this->id > 0) {
$item = I18n::fetch($this->id);
if ($item->id > 0) {
$item->delete();
$itemTranslate = I18nTranslate::fetch($this->id);
$itemTranslate->delete();
$this->redirect(SiteHelper::createUrl("/console/variable"));
}
}
$this->redirect(SiteHelper::createUrl("/console/variable"));
}