本文整理汇总了PHP中BaseModel::save方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::save方法的具体用法?PHP BaseModel::save怎么用?PHP BaseModel::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseModel
的用法示例。
在下文中一共展示了BaseModel::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save()
{
parent::save();
$cache = Project::getDatabaseManager()->getCache();
if ($cache !== null) {
}
}
示例2: save
public function save(array $options = [])
{
if (isset($this->password) && strcmp($this->getOriginal('password'), $this->password) !== 0) {
$this->password = self::makePass($this->password);
}
parent::save($options);
}
示例3: save
/**
* Extending save method to add author before save
*
* @return void
* @author Gat
**/
public function save(array $options = array())
{
// Add author if not set
if (!isset($this->author_id)) {
$this->author_id = Auth::user()->id;
}
parent::save($options);
}
示例4: save
/**
* Extending save method to add encoder before save
*
* @return void
* @author Gat
**/
public function save(array $options = array())
{
// Add encoder if not set
if (!isset($this->secretary_id)) {
$this->secretary_id = Auth::user()->id;
}
parent::save($options);
}
示例5: save
function save()
{
// Убираем текстовые поля
unset($this->_data['country'], $this->_data['state'], $this->_data['city']);
// ----------------------
$result = parent::save();
return $result;
}
示例6: save
function save()
{
parent::save();
$cache = Project::getDatabaseManager()->getCache();
if ($cache !== null) {
$cache->delete($this->getCachePrefix('_list_user_type_' . $this->user_type_id));
$cache->delete($this->getCachePrefix('_list_controller_user_type_' . $this->user_type_id));
$cache->delete($this->getCachePrefix('_list_controller_action_user_type_' . $this->user_type_id . $this->controller_id . $this->action_id));
}
}
示例7: save
/**
* 重写save方法,修改角色权限信息
* @param mixed|string $requestData
* @return bool
*/
public function save($requestData)
{
//修改角色信息
$rst = parent::save();
if ($rst === false) {
return false;
}
//修改角色权限信息
$rst = $this->handleRolePermission($requestData['id'], $requestData['permission_ids']);
if ($rst === false) {
return false;
}
return $rst;
}
示例8: onStore
/**
* Perform actions after new user has been stored
* @param BaseModel $user User that has just been stored
*/
public function onStore($user)
{
// Make the first user SuperAdmin
if (count(User::all()) == 1 && !$user->hasRole('Super Admin')) {
$user->roles()->attach(Role::where('name', '=', 'Super Admin')->firstOrFail());
Log::debug(e($user->username) . ': Assigning "Super Admin" role as first user to log in', [$user->api_key]);
}
// Generate an API key if the user does not have one
if (empty($user->api_key)) {
$user->api_key = md5(str_random(32));
$user->save();
Log::debug(e($user->username) . ': Generating API key', [$user->api_key]);
}
}
示例9: save
/**
* @return mixed
*/
public function save()
{
$id = parent::save();
$cashAccounts = Table_Cashaccounts::getInstance();
$select = $cashAccounts->select()->where('resident_id = ?', $id);
$rows = $cashAccounts->fetchAll($select);
if ($rows->count() > 0) {
// found needs update
$rows->current()->save();
} else {
// not found
// means new resitend -> create an cash account
$cashAccounts->createRow(array('resident_id' => $id))->save();
}
return $id;
}
示例10: save
public function save($postData)
{
//保存文章信息
$result = parent::save();
if ($result === false) {
return fasle;
}
//保存文章内容 >> 删除原有,在添加
$articleContent = M('ArticleContent');
$id = $postData['id'];
//删除
$rst = $articleContent->where('article_id=' . $id)->delete();
if ($rst === false) {
$this->error = '删除文章内容失败';
return false;
}
//添加
$rst = $articleContent->add(array('article_id' => $id, 'content' => $postData['content']));
if ($rst === false) {
$this->error = '添加文章内容失败';
return false;
}
return $result;
}
示例11: changeStatus
public function changeStatus($id, $status = -1)
{
//开启事物
$this->startTrans();
$goods_data = array('status' => $status, 'id' => array('in', $id));
$goods_intro_data = array('status' => $status, 'goods_id' => array('in', $id));
if ($status == -1) {
$data['name'] = array('exp', "CONCAT(name,'_del')");
}
//删除goods表数据
$rst = parent::save($goods_data);
if ($rst === false) {
$this->rollback();
$this->error = '删除商品失败!';
return false;
}
//删除goods_intro表数据
$model = M('GoodsIntro');
$result = $model->save($goods_intro_data);
if ($result === false) {
$this->rollback();
$this->error = '删除描述失败!';
return false;
}
//删除goods_member_price表信息
$model = D('GoodsMemberPrice');
//先删除id对应的数据
$result = $model->where("goods_id={$id}")->delete();
if ($result === false) {
$this->rollback();
$this->error = '删除分级价格失败!';
return false;
}
$this->commit();
return $rst;
}
示例12: save
/**
* Save the model.
*
* @param array $options
* @return mixed
*/
public function save(array $options = [])
{
\Cache::forever(self::getCacheKey($this->localizable_id, $this->region_code), json_encode($this->localizations));
parent::save($options);
}
示例13: updatePassword
/**
* 修改密码
* @param $requestData
* @return bool
*/
public function updatePassword($requestData)
{
//验证就密码是否正确
$userinfo = login();
$row = $this->field('password,salt')->where(array('id' => $userinfo['id']))->find();
if (myMd5($requestData['old_password'], $row['salt']) != $row['password']) {
$this->error = '密码错误';
return false;
}
//修改密码
$data = array('id' => $userinfo['id'], 'password' => myMd5($requestData['password'], $row['salt']));
return parent::save($data);
}
示例14: save
/**
* 重写修改
* @param mixed|string $postData
* @return bool
*/
public function save($postData)
{
// dump($postData);exit;
$this->startTrans();
$id = $postData['id'];
//1> 修改到goods表中
$this->handleStatus();
$result = parent::save();
if ($result === false) {
$this->rollback();
return false;
}
//2> 修改到goods_intro表中
$result1 = $this->handleIntro($id, $postData['intro']);
if ($result1 === false) {
return fasle;
}
//3> 修改到goods_member_price表中
$result1 = $this->handleMemberPrice($id, $postData['memberPrices']);
if ($result1 === false) {
return fasle;
}
//4> 处理商品相册
if (isset($postData['goods_gallerys'])) {
$result1 = $this->handleGallery($id, $postData['goods_gallerys']);
if ($result1 === false) {
return fasle;
}
}
//>5处理相关文章
if (isset($postData['article_ids'])) {
$result1 = $this->handleArticle($id, $postData['article_ids']);
if ($result1 === false) {
return fasle;
}
}
//6> 修改到goods_attribute表中
$result1 = $this->updateAttribute($id, $postData['attribute']);
if ($result1 === false) {
return fasle;
}
$this->commit();
return $result;
}
示例15: save
public function save()
{
$errors = [];
// Validation
if (!self::isEmailValid($this->email)) {
$errors[] = 'Email is Invalid';
}
if (isset($this->password) && !self::isPasswordValid($this->password)) {
$errors[] = 'Password is Invalid';
}
$this->setStripeData($this->stripe_data);
// convert to JSON
$this->addErrors($errors);
// add any errors
// Add Secret Fields to Field List
if (isset($this->password)) {
$this->modelFields[] = 'password';
}
// Hash the Password (encrypt)
if (isset($this->password)) {
$this->password = self::hashPassword($this->password);
}
// Validation Outcome?
return count($errors) ? false : parent::save();
}