本文整理汇总了PHP中self::save方法的典型用法代码示例。如果您正苦于以下问题:PHP self::save方法的具体用法?PHP self::save怎么用?PHP self::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类self
的用法示例。
在下文中一共展示了self::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getModelByMobile
public static function getModelByMobile($mobile)
{
$model = null;
if (\Yii::$app->mutex->acquire(self::tableName(), self::SCENE_LOCK_WAIT_TIME_SECOND)) {
$model = self::findOne(['mobile' => $mobile]);
if (empty($model)) {
$model = new self();
$model->mobile = $mobile;
$model->created_at = time();
$model->save(false);
}
\Yii::$app->mutex->release(self::tableName());
if ($model->updated_at + $model->expire_seconds < time()) {
$gh_id = MGh::GH_XIANGYANGUNICOM;
\Yii::$app->wx->setGhId($gh_id);
$scene_id = $model->scene_id + 100000;
$arr = \Yii::$app->wx->WxgetQRCode($scene_id, 0, 300);
$model->updated_at = time();
$model->ticket = $arr['ticket'];
$model->expire_seconds = $arr['expire_seconds'];
$model->url = $arr['url'];
$qr_url = \Yii::$app->wx->WxGetQRUrl($arr['ticket']);
$log_file_path = \Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'qr' . DIRECTORY_SEPARATOR . "{$gh_id}_{$scene_id}.jpg";
Wechat::downloadFile($qr_url, $log_file_path);
$model->qr_url = \Yii::$app->getRequest()->baseUrl . "/../runtime/qr/{$gh_id}_{$scene_id}.jpg";
$model->save(false);
}
} else {
\Yii::error('acquire lock error');
}
return $model;
}
示例2: register
public static function register(\Exception $e)
{
$ee = new self();
$ee->exception = serialize($e);
$ee->save();
$ee->reload();
$ee->exception_hash = sha1(md5($ee->exceptionid . __CLASS__) . "." . sha1($ee->exceptionid . __METHOD__));
$ee->save();
return $ee->exception_hash;
}
示例3: createByProductIds
/**
* @param int[] $ids
*
* @return Check
*/
public static function createByProductIds($ids)
{
$check = new self();
$check->save();
foreach ($ids as $id) {
$product = Product::find()->where(['id' => $id])->one();
if ($product === null) {
continue;
}
$check->link('products', $product);
}
$check->calculate();
$check->save();
return $check;
}
示例4: saveData
public function saveData($request, $member_id = '')
{
// Upload
$file_upload = Input::file('avatar');
$avatar = '';
if ($file_upload) {
$filename = $file_upload->getClientOriginalName();
$extension = $file_upload->getClientOriginalExtension();
$avatar = sha1($filename . time()) . '.' . $extension;
$destinationPath = config('custom.path_upload_member');
$file_upload->move($destinationPath, $avatar);
}
if ($member_id) {
$member = self::find($member_id);
} else {
$member = new self();
}
$member->avatar = $avatar ? $avatar : $member->avatar;
$member->fullname = $request->input('fullname', '');
$member->team = $request->input('team_id', '');
$results = $member->save();
if ($results) {
return $member->id;
} else {
return $results;
}
}
示例5: migrate
/**
* Метод выполения миграций
* @param string $name уникальное название миграции
* @return array массив списка результатов
*/
public static function migrate($name)
{
$migration = new self();
$migration->migration = $name;
$migration->save();
self::$operations[] = "Миграция {$name} успешно выполнена\n";
}
示例6: add
public static function add($params)
{
$game = new self();
$game->member_id = $params->member_id;
$game->subgame_id = $params->game_id;
$game->save();
}
示例7: doAddRemove
/**
* Add or Remove an order item to/from a server
*
*
* @param integer $orderItemID
* @param integer $serverID
*/
private static function doAddRemove($orderItemID, $serverID, $action = '')
{
$ret = false;
if (is_numeric($orderItemID) && is_numeric($serverID) && ($action == 'add' || $action == 'remove')) {
$serverID = intval($serverID);
$itemID = intval($orderItemID);
if ($action == 'remove') {
$record = self::findByServerAndItem($serverID, $itemID);
$record->delete();
$ret = true;
} else {
$order = OrdersItems::find($orderItemID, 'order_id', true);
if (!empty($order) && is_array($order) && count($order) > 0) {
$order = $order[0];
if (!isset($order['order_id']) || intval($order['order_id']) == 0) {
$ret = false;
}
$orderID = intval($order['order_id']);
$OrdersItemsServers = new self();
$OrdersItemsServers->server_id = $serverID;
$OrdersItemsServers->order_id = $orderID;
$OrdersItemsServers->orderitem_id = $itemID;
$OrdersItemsServers->save();
$ret = true;
}
}
// Always update server stats
$Server = Servers::find($serverID);
$Server->services = OrdersItemsServers::countByServerId($serverID);
$Server->save();
return $ret;
}
return false;
}
示例8: create
/**
* Create a log object
*
* @access public
* @param string $action
* @param object $object
*/
public static function create($action, $object = null)
{
// what class is it
$classname = '';
if (!is_null($object)) {
$classname = strtolower(get_class($object));
}
$log = new self();
try {
$user = User::get();
$log->user_id = $user->id;
} catch (\Exception $e) {
$log->user_id = 0;
}
if ($action == 'add') {
$content = ucfirst($classname) . ' created';
} elseif ($action == 'edit') {
$content = ucfirst($classname) . ' edited';
} else {
$content = ucfirst($action);
}
$log->classname = $classname;
$log->object_id = !is_null($object) ? $object->id : 0;
$log->content = $content;
$log->save();
return $log;
}
示例9: add
public static function add($params)
{
$flag = new self();
$flag->member_id = $params->member_flagged;
$flag->flagged_by = $params->flagged_by;
$flag->save();
}
示例10: subscribeUser
/**
* Subscribe a user to the topic
*
*/
public function subscribeUser($topicId, $userId)
{
$model = new self();
$model->topicid = $topicId;
$model->userid = $userId;
$model->save();
}
示例11: saveNewUrl
public static function saveNewUrl($url)
{
$model = new self('updateUrls');
$model->page_url = $url;
$model->save();
\Yii::app()->setGlobalState('DisqusComments', microtime(true));
}
示例12: createTopic
public static function createTopic($user, $topicFields)
{
$topic = new self($topicFields);
$topic->author_id = $user->id;
$topic->save();
return $topic;
}
示例13: getByKey
/**
* @static
* @param $id - translation key
* @param bool $create - creates an empty translation entry if the key doesn't exists
* @param bool $returnIdIfEmpty - returns $id if no translation is available
* @return Translation_Website
*/
public static function getByKey($id, $create = false, $returnIdIfEmpty = false)
{
$translation = new self();
try {
$translation->getResource()->getByKey($id);
} catch (Exception $e) {
if (!$create) {
throw new Exception($e->getMessage());
} else {
$translation->setKey($id);
$translation->setDate(time());
$translations = array();
foreach (Pimcore_Tool::getValidLanguages() as $lang) {
$translations[$lang] = "";
}
$translation->setTranslations($translations);
$translation->save();
}
}
if ($returnIdIfEmpty) {
$translations = $translation->getTranslations();
foreach ($translations as $key => $value) {
$translations[$key] = $value ?: $id;
}
$translation->setTranslations($translations);
}
return $translation;
}
示例14: addOne
/**
* Add new notification
*
* @param $user_id
* @param $review_id
*/
public static function addOne($user_id, $review_id)
{
$obj = new self();
$obj->from_array(array('user_id' => $user_id, 'review_id' => $review_id, 'created' => time()));
$obj->save();
return $obj;
}
示例15: saveData
public function saveData($request, $user_id = '')
{
$password = '';
$role_id = $request->input('role_id');
if ($user_id) {
$user = self::find($user_id);
//Dectach
$detact = $user->roles()->detach();
$password = $user->password;
} else {
// Check duplicate
$email = $request->input('email');
$check_user = self::where('email', '=', $email)->first();
if ($check_user) {
return false;
} else {
$user = new self();
}
}
$new_password = bcrypt($request->input('password'));
if (!$new_password) {
$new_password = $password;
}
$user->name = $request->input('name');
$user->email = $request->input('email');
$user->password = $new_password;
$results = $user->save();
if ($results) {
$results_return = $user->roles()->attach($role_id);
return $user->id;
} else {
return $results;
}
}