当前位置: 首页>>代码示例>>PHP>>正文


PHP Record::update方法代码示例

本文整理汇总了PHP中Record::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Record::update方法的具体用法?PHP Record::update怎么用?PHP Record::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Record的用法示例。


在下文中一共展示了Record::update方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_user_key

function add_user_key($user_name, $user_id)
{
    // some random string
    $random = sha1(microtime() . rand());
    // insert random string into user_key colomn
    Record::update('User', array('user_key' => $random), 'id = :user_id', array(':user_id' => (int) $user_id));
}
开发者ID:svanlaere,项目名称:adduserdata,代码行数:7,代码来源:index.php

示例2: update

 public static function update($model, $id, $update_lit = '')
 {
     Session::permit_admin();
     $success = parent::update(Record::allow($model, ['title', 'name', 'type']), $id, $update_lit);
     if (isset($model['content'])) {
         $success = DocContent::create(['doc_id' => $id, 'content' => $model['content']]);
     }
     if (isset($model['routes'])) {
         DocRoute::destroy_all($id);
         if ($model['routes']) {
             $routes = [];
             foreach (explode(',', $model['routes']) as $route_def) {
                 $parts = explode('=>', $route_def);
                 $route = trim($parts[0]);
                 if (strlen($route) == 0 || $route[0] != '/') {
                     $route = '/' . $route;
                 }
                 $handler = count($parts) > 1 ? trim($parts[1]) : null;
                 $routes[] = ['doc_id' => $id, 'route' => $route, 'handler' => $handler ? $handler : null];
             }
             DocRoute::create_all($routes);
         }
     }
     return $success;
 }
开发者ID:wileybenet,项目名称:mobile-docs,代码行数:25,代码来源:doc.php

示例3: save

 function save()
 {
     $data = $_POST['redirect'];
     if (empty($data['url'])) {
         Flash::set('error', __('You have to specify a url!'));
         redirect(get_url('plugin/redirector/'));
     }
     if (empty($data['destination'])) {
         Flash::set('error', __('You have to specify a destination url!'));
         redirect(get_url('plugin/redirector/'));
     }
     if ($existing_redirect = Record::findOneFrom('RedirectorRedirects', 'url = \'' . ($data['url'] . '\''))) {
         Record::update('RedirectorRedirects', array('url' => $data['url'], 'destination' => $data['destination']), 'url = \'' . ($data['url'] . '\''));
     } else {
         $entry = new RedirectorRedirects($data);
         if (!$entry->save()) {
             Flash::set('error', __('There was a problem adding your redirect.'));
         } else {
             if ($error = Record::findOneFrom('Redirector404s', 'url = \'' . ($data['url'] . '\''))) {
                 $error->delete();
             }
             Flash::set('success', __('Redirect has been added!'));
         }
     }
     redirect(get_url('plugin/redirector/'));
 }
开发者ID:julpi,项目名称:FreshCMS,代码行数:26,代码来源:RedirectorController.php

示例4: update_one

 public static function update_one($model, $id)
 {
     $model = Record::allow($model, ['email', 'password', 'auth']);
     if (isset($model['password'])) {
         $model['password'] = crypt($model['password'], SALT);
     }
     return parent::update($model, $id);
 }
开发者ID:wileybenet,项目名称:mobile-docs,代码行数:8,代码来源:user.php

示例5: update

 public static function update($model, $id, $update_lit = '')
 {
     $success = parent::update(self::allow($model, ['title', 'summary']), $id, $update_lit);
     if (isset($model['content'])) {
         $success = SolutionContent::create(['solution_id' => $id, 'content' => $model['content']]);
     }
     return $success;
 }
开发者ID:wileybenet,项目名称:mobile-docs,代码行数:8,代码来源:solution.php

示例6: testShouldUpdateDateFromArray

 public function testShouldUpdateDateFromArray()
 {
     $update = array('name' => 'Jéssica Santana');
     $record = new Record();
     $record->name = 'Henrique Moody';
     $record->update($update);
     $this->assertEquals($update['name'], $record->name);
 }
开发者ID:elevenone,项目名称:ArrayStorage,代码行数:8,代码来源:RecordTest.php

示例7: comment_on_page_saved

function comment_on_page_saved($page)
{
    $status = Comment::NONE;
    $input = $_POST['page'];
    if (isset($input['comment_status']) && is_int((int) $input['comment_status'])) {
        $status = $input['comment_status'];
    }
    Record::update('Page', array('comment_status' => $status), 'id = ?', array($page->id));
}
开发者ID:crick-ru,项目名称:wolfcms,代码行数:9,代码来源:index.php

示例8: redirector_log_404

function redirector_log_404()
{
    $redirect = Record::findAllFrom('Redirector404s', 'url = \'' . $_SERVER['REQUEST_URI'] . '\'');
    if (sizeof($redirect) > 0) {
        Record::update('Redirector404s', array('hits' => $redirect[0]->hits + 1), 'id = ' . $redirect[0]->id);
    } else {
        Record::insert('Redirector404s', array('url' => $_SERVER['REQUEST_URI']));
    }
}
开发者ID:julpi,项目名称:FreshCMS,代码行数:9,代码来源:index.php

示例9: update_location

 public static function update_location($doc)
 {
     $nav = self::read_by_doc($doc['id']);
     $changes = [];
     if (array_key_exists('parent_id', $doc)) {
         $changes['parent_doc_id'] = $doc['parent_id'];
     }
     if (array_key_exists('order', $doc)) {
         $changes['sort_order'] = $doc['order'];
     }
     parent::update($changes, $nav['id']);
 }
开发者ID:wileybenet,项目名称:mobile-docs,代码行数:12,代码来源:nav.php

示例10: dirname

<?php

require_once dirname(__FILE__) . './vendor/autoload.php';
//autoload packages
use McKay\Flash;
chk_lgn();
$db = new Database();
$user = new User($db->conn);
$record = new Record($db->conn);
if ($_POST) {
    $id = $_POST['id'];
    $update = $_POST['record'];
    if ($record->update($id, $update)) {
        Flash::success('Record Successfully Updated!!');
        unset($_POST);
    } else {
        Flash::error('Record Could Not Be Updated!!');
    }
}
if (isset($_GET['id'])) {
    $user_id = $_GET['id'];
} else {
    $user_id = $_SESSION['user_id'];
}
$data = $record->read($user_id);
require 'templates/header.php';
?>

<div id="page-wrapper">

<div class="container-fluid">
开发者ID:NimzyMaina,项目名称:maternal,代码行数:31,代码来源:record.php

示例11: setTags

 public function setTags($tags)
 {
     if (is_string($tags)) {
         $tags = explode(',', $tags);
     }
     $tags = array_map('trim', $tags);
     $current_tags = $this->getTags();
     // no tag before! no tag now! ... nothing to do!
     if (count($tags) == 0 && count($current_tags) == 0) {
         return;
     }
     // delete all tags
     if (count($tags) == 0) {
         $tablename = self::tableNameFromClassName('Tag');
         // update count (-1) of those tags
         foreach ($current_tags as $tag) {
             Record::update('Tag', array('count' => 'count - 1'), 'name = :tag_name', array(':tag_name' => $tag));
         }
         return Record::deleteWhere('PageTag', 'page_id = :page_id', array(':page_id' => $this->id));
     } else {
         $old_tags = array_diff($current_tags, $tags);
         $new_tags = array_diff($tags, $current_tags);
         // insert all tags in the tag table and then populate the page_tag table
         foreach ($new_tags as $index => $tag_name) {
             if (!empty($tag_name)) {
                 // try to get it from tag list, if not we add it to the list
                 if (!($tag = Tag::findByName($tag_name))) {
                     $tag = new Tag(array('name' => trim($tag_name)));
                 }
                 $tag->count++;
                 $tag->save();
                 // create the relation between the page and the tag
                 $tag = new PageTag(array('page_id' => $this->id, 'tag_id' => $tag->id));
                 $tag->save();
             }
         }
         // remove all old tag
         foreach ($old_tags as $index => $tag_name) {
             // get the id of the tag
             $tag = Tag::findByName($tag_name);
             // delete the pivot record
             Record::deleteWhere('PageTag', 'page_id = :page_id AND tag_id = :tag_id', array(':page_id' => $this->id, ':tag_id' => $tag->id));
             $tag->count--;
             $tag->save();
         }
     }
 }
开发者ID:ariksavage,项目名称:superior-optical-eyewear,代码行数:47,代码来源:Page.php

示例12: saveFromData

 public static function saveFromData($data)
 {
     foreach ($data as $name => $value) {
         Record::update('Setting', array('value' => $value), 'name = :name', array(':name' => $name));
     }
 }
开发者ID:ariksavage,项目名称:superior-optical-eyewear,代码行数:6,代码来源:Setting.php


注:本文中的Record::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。