本文整理汇总了PHP中A::save方法的典型用法代码示例。如果您正苦于以下问题:PHP A::save方法的具体用法?PHP A::save怎么用?PHP A::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类A
的用法示例。
在下文中一共展示了A::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new A();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['A'])) {
$model->attributes = $_POST['A'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例2: testCaching
public function testCaching()
{
$a = new A();
$a->a = 1;
$a->uniqueRequiredEmail = 'a@zurmoinc.com';
$this->assertTrue($a->save());
$originalAHash = spl_object_hash($a);
$id = $a->id;
unset($a);
$a = A::getById($id);
$fromPhpAHash = spl_object_hash($a);
unset($a);
RedBeanModelsCache::forgetAll(true);
$a = A::getById($id);
$this->assertEquals(1, $a->a);
$this->assertEquals('a@zurmoinc.com', $a->uniqueRequiredEmail);
$fromMemcacheAHash = spl_object_hash($a);
$this->assertEquals($fromPhpAHash, $originalAHash);
$this->assertNotEquals($fromMemcacheAHash, $originalAHash);
}
示例3: testForgetAll
public function testForgetAll()
{
$a = new A();
$a->a = 1;
$a->uniqueRequiredEmail = 'a3@zurmoinc.com';
$this->assertTrue($a->save());
$modelIdentifier = $a->getModelIdentifier();
$modelFromCache = RedBeanModelsCache::getModel($modelIdentifier);
$this->assertEquals(1, $modelFromCache->a);
$this->assertEquals('a3@zurmoinc.com', $modelFromCache->uniqueRequiredEmail);
// Set some GeneralCache, which should stay in cache after cleanup
GeneralCache::cacheEntry('somethingForTesting', 34);
$value = GeneralCache::getEntry('somethingForTesting');
$this->assertEquals(34, $value);
RedBeanModelsCache::forgetAll();
try {
RedBeanModelsCache::getModel($modelIdentifier);
$this->fail('NotFoundException exception is not thrown.');
} catch (NotFoundException $e) {
// Data from generalCache should still be in cache
$value = GeneralCache::getEntry('somethingForTesting');
$this->assertEquals(34, $value);
}
}
示例4: actionImport
public function actionImport()
{
$model = new A();
if (isset($_POST['A'])) {
Yii::import('ext.phpexcelreader.excel_reader2', true);
$model->attributes = $_POST['A'];
$import = CUploadedFile::getInstance($model, 'filee');
if ($import == null) {
Yii::app()->user->setFlash('error', 'File Kosong');
$this->redirect(array(''));
} else {
$import->saveAs('coba/' . $import);
}
if ($import->type == "application/ynd.ms.excel") {
$data = new Spreadsheet_Excel_Reader('/../controller/coba1.xls/');
echo $data->dump(true, true);
$id = array();
$nama = array();
for ($j = 2; $j <= $data->rowcount(); $j++) {
if (empty($data->sheets[0]['cells'][$j][1]) || empty($data->sheets[0]['cells'][$j][2])) {
Yii::app()->user->setFlash('error', 'Data Gagal di Import (File excel harus diisi semua)');
$id[$j] = null;
$nama[$j] = null;
} else {
$id[$j] = $data->sheets[0]['cells'][$j][1];
$nama[$j] = $data->sheets[0]['cells'][$j][2];
}
}
$niki = $data->rowcount(0);
for ($i = 1; $i < $niki; $i++) {
$model = new A();
$model->id = $id[$i];
$model->nama = $nama[$i];
$model2 = A::model()->findByPk($id[$i]);
if ($model2 != null) {
Yii::app()->user->setFlash('error', 'Data Gagal di Import (NIDN sudah ada sebelumnya)');
$this->redirect(array('import'));
} else {
$model->save();
}
}
$this->redirect(array('index'));
} else {
Yii::app()->user->setFlash('error', 'Format file tidak dikenali (format file harus .xls)');
$this->redirect(array('import'));
}
}
$this->render('import', array('model' => $model));
/* $model = new A();
if (isset($_POST['A'])) {
$model->attributes = $_POST['A'];
$itu = CUploadedFile::getInstance($model, 'filee');
$path = 'coba1.xls';
//$itu->saveAs($path);
$data = new Spreadsheet_Excel_Reader('coba1.xls');
}*/
}
示例5: loginSocial
/**
* @return bool
* @throws \Auth\AuthException
*/
public function loginSocial()
{
if (!$this->session->token) {
if (isset($_POST['token']) && isset($_SERVER['HTTP_HOST'])) {
$s = file_get_contents('http://ulogin.ru/token.php?token=' . $_POST['token'] . '&host=' . $_SERVER['HTTP_HOST']);
$result = json_decode($s, true);
$userProviders = UserProviders::find(['uid' => $result['uid']])[0];
$auth = new A();
$auth->user_id = $userProviders->user_id;
$auth->provider_id = $userProviders->provider_id;
$auth->token = uniqid();
$auth->save();
$this->session->token = $auth->token;
$this->session->user = User::find(['id' => $auth->user_id])[0];
return true;
}
} else {
throw new AuthException('You are already logged in!');
}
}