本文整理汇总了PHP中Preferences::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Preferences::save方法的具体用法?PHP Preferences::save怎么用?PHP Preferences::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preferences
的用法示例。
在下文中一共展示了Preferences::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPreference
public function setPreference($user_id, $key, $value)
{
$result = Doctrine_Query::create()->from('Preferences p')->andwhere('p.user_ref = ?', $user_id)->andWhere('p.pref_key = ?', $key)->fetchOne();
if (!$result) {
$result = new Preferences();
$result->fromArray(array('user_ref' => $user_id, 'pref_key' => $key));
}
$result->setPrefValue($value);
$result->save();
return true;
}
示例2: actionCreate
public function actionCreate()
{
$model = new Clients();
$account = new Accounts();
$preference = new Preferences();
if (isset($_POST['Clients'], $_POST['Accounts'], $_POST['Preferences'])) {
$model->attributes = $_POST['Clients'];
$account->attributes = $_POST['Accounts'];
$preference->attributes = $_POST['Preferences'];
$model->login_name = $account->login_name;
$model->client_code = RandomGenerator::generateString(AdminGlobals::CLIENT_CODE_LENGTH);
$model->subscription_status = "active";
$preference->prepaid_passwd = RandomGenerator::generateString(AdminGlobals::PREPAID_PASSWD_LENGTH);
$account->account_name = $model->client_name;
$account->email = $model->email;
$account->is_visible = 0;
$valid = $model->validate();
$valid = $account->validate() && $valid;
$valid = $preference->validate() && $valid;
if ($valid) {
$transaction = Yii::app()->db->beginTransaction();
$success = $model->save(false);
if ($success) {
$account->client_id = $preference->client_id = $model->id;
}
$success = $success && $account->save(false);
$success = $success && $preference->save(false);
if ($success) {
$transaction->commit();
if (Yii::app()->request->isAjaxRequest) {
$this->renderPartial('view', array('model' => $this->loadModel($model->id), 'account' => $account, 'preference' => $preference), false, true);
Yii::app()->end();
}
$this->redirect(array('view', 'id' => $model->id));
}
$transaction->rollBack();
}
}
if (Yii::app()->request->isAjaxRequest) {
$this->renderPartial('create', array('model' => $model, 'account' => $account, 'preference' => $preference), false, true);
Yii::app()->end();
}
$this->render('create', array('model' => $model, 'account' => $account, 'preference' => $preference));
}
示例3: actionSearchSample
public function actionSearchSample()
{
$id = CommonTools::getBiobankInfo();
if (Yii::app()->user->isGuest) {
$this->redirect(array('login', 'id' => $id));
}
$model = new Sample('search');
$model->unsetAttributes();
$model->biobank_id = $id;
$prefs = Preferences::model()->findByAttributes(array('id_user' => Yii::app()->user->id));
if ($prefs == null) {
$prefs = new Preferences();
$prefs->id_user = Yii::app()->user->id;
$prefs->save();
}
if (isset($_GET['Preferences'])) {
$prefs->attributes = $_GET['Preferences'];
$prefs->save();
}
if (isset($_GET['Sample'])) {
$model->attributes = $_GET['Sample'];
$content = '';
foreach ($_GET['Sample'] as $key => $value) {
if ($value != null && !empty($value) && (string) $value != '0') {
$content = $content . (string) $key . '=' . str_replace(';', ',', (string) $value) . ';';
}
}
if (Yii::app()->session['SampleForm'] != $_GET['Sample']) {
$_GET['Echantillon_page'] = null;
}
Yii::app()->session['SampleForm'] = $_GET['Sample'];
}
//form de la recherche intelligente
$smartForm = new SampleSmartForm();
if (isset($_POST['SampleSmartForm'])) {
$model->unsetAttributes();
$model->biobank_id = $id;
$smartForm->attributes = $_POST['SampleSmartForm'];
if (Yii::app()->session['keywords'] != $smartForm->keywords) {
$_GET['Echantillon_page'] = null;
}
Yii::app()->session['keywords'] = $smartForm->keywords;
$model = SmartResearcherTool::search($smartForm->keywords, $id);
}
$this->render('search_samples', array('model' => $model, 'smartForm' => $smartForm));
}
示例4: Preferences
<?php
$prefs = Preferences::model()->findByAttributes(array('id_user' => Yii::app()->user->id));
if ($prefs == null) {
$prefs = new Preferences();
$prefs->id_user = Yii::app()->user->id;
$prefs->save();
}
$prefsNames = Preferences::model()->attributeNames();
$scriptCB = '';
foreach ($prefsNames as $property) {
if ($property != 'id_user') {
$scriptCB = $scriptCB . '$(\'#Preferences_' . $property . '\').change(function(){
$(\'.col_' . $property . '\').toggle();
$(\'.prefs-form form\').submit();
return false;
});
';
}
}
// recharge le tableau d'affichage des échantillons après envoi du formulaire de recherche avancée
Yii::app()->clientScript->registerScript('search', "\n\$('.smart-search-form form').submit(function(){\n\t\$('#sample-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\n\treturn false;\n});\n\$('.prefs-form form').submit(function(){\n\t\$('#sample-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\t\t\n\treturn false;\n});\n{$scriptCB};\n");
?>
<h1><?php
echo Yii::t('common', 'searchsamples');
?>
</h1>
<div style="margin: 5px;"><?php
echo Yii::t('common', 'totalnumbersamples');