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


PHP Date::forge方法代码示例

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


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

示例1: render

 public static function render($app, $ref_id, $title = 'Comments')
 {
     if (!isset($app)) {
         throw new \FuelException('Petro_Comment : Invalid $app = ' . $app);
     }
     $query = \DB::query('SELECT ' . static::$_table . '.*, users.username FROM ' . static::$_table . ', users' . ' WHERE ' . static::$_table . '.user_id = users.id' . ' AND ' . static::$_table . '.app = "' . $app . '"' . ' AND ' . static::$_table . '.ref_id = ' . $ref_id . ' ORDER BY ' . static::$_table . '.created_at asc')->execute();
     $data['title'] = $title;
     $data['app'] = $app;
     $data['ref_id'] = $ref_id;
     $data['total_comments'] = count($query);
     if ($data['total_comments'] <= 0) {
         $data['comments'] = str_replace('{text}', 'No comments yet.', \Config::get('petro.template.comment.empty'));
     } else {
         $t = \Config::get('petro.template.comment.item');
         $out = '';
         foreach ($query as $item) {
             $author = isset($item['username']) ? $item['username'] : 'Anonymous';
             $date = empty($item['created_at']) ? '' : \Date::forge($item['created_at'])->format(\Config::get('petro.date_format', '%Y-%m-%d %H:%M'));
             $cost = empty($item['cost']) ? '' : number_format($item['cost']);
             $out .= str_replace(array('{comment_id}', '{comment_author}', '{comment_date}', '{comment_text}', '{comment_cost}'), array($item['id'], $author, $date, nl2br($item['text']), $cost), $t);
         }
         $data['comments'] = $out;
     }
     $data['last_url'] = \Uri::current();
     return \View::forge('petro/comments/_form', $data, false)->render();
 }
开发者ID:ratiw,项目名称:petro,代码行数:26,代码来源:comment.php

示例2: action_edit

 public function action_edit($id = null)
 {
     $client = Model_Client::find($id);
     $form = $this->setup_form();
     if (Input::method() == 'POST') {
         if ($form->validation()->run() === true) {
             $fields = $form->validated();
             $client->code = $fields['code'];
             $client->name = $fields['name'];
             $client->name_en = $fields['name_en'];
             $client->status = $fields['status'];
             $client->updated_at = Date::forge()->get_timestamp();
             if ($client->save()) {
                 Session::set_flash('success', 'Updated client #' . $id);
                 Response::redirect('clients');
             } else {
                 Session::set_flash('error', 'Could not update client #' . $id);
             }
         } else {
             $this->template->set_global('errors', $form->error(), false);
         }
     }
     $this->template->page_title = "Edit Client";
     $this->template->set('content', $form->build($client), false);
 }
开发者ID:ratiw,项目名称:petro-test,代码行数:25,代码来源:clients.php

示例3: getFleamarkets

 /**
  * 対象のフリマを取得
  *
  * @access private
  * @return Model_Fleamarket array
  */
 private function getFleamarkets()
 {
     $target_event_statuses = array(\Model_Fleamarket::EVENT_STATUS_SCHEDULE, \Model_Fleamarket::EVENT_STATUS_RESERVATION_RECEIPT, \Model_Fleamarket::EVENT_STATUS_RECEIPT_END);
     $date = \Date::forge(strtotime('- 1 day'));
     $fleamarkets = \Model_Fleamarket::find('all', array('select' => array('fleamarket_id', 'event_status'), 'where' => array(array('event_date', '<=', $date->format('mysql')), array('register_type', '=', \Model_Fleamarket::REGISTER_TYPE_ADMIN), array('event_time_end', '<=', $date::time()->format('mysql')), array('event_status', 'IN', $target_event_statuses))));
     return $fleamarkets;
 }
开发者ID:eva-tuantran,项目名称:use-knife-solo-instead-chef-solo-day13,代码行数:13,代码来源:fleamarket_event_close.php

示例4: action_review

 public function action_review($pid)
 {
     $this->template->title = "旅ログ";
     $ret = Model_Members_General::getPostHeader($pid);
     $first = array_shift($ret);
     // ********************************
     if (Input::method() == 'POST') {
         /*--------
           ユーザが入力した値とその時の時刻を保持
           ------*/
         $first['input_title'] = Input::post('title');
         $first['input_comment'] = Input::post('comment');
         $first['input_rating'] = Input::post('rating');
         $time = Date::forge()->get_timestamp();
     }
     /*-----------
       Validationの準備
       -----------*/
     //Validationオブジェクトを呼び出す
     $val = Validation::forge();
     //フォームのルール設定
     $val->add('title', 'タイトル')->add_rule('required')->add_rule('max_length', 30);
     $val->add('comment', 'コメント')->add_rule('required');
     //コメントの長さ制限いる?
     $val->add('rating', '評価')->add_rule('required');
     //Validationチェック
     if ($val->run()) {
         /*------------
           postされた各データをDBに保存
           ----------------*/
         $props = array('uid' => $this->viewer_info['uid'], 'pid' => $pid, 'title' => $first['input_title'], 'comment' => $first['input_comment'], 'rating' => $first['input_rating'], 'datetime' => $time);
         //モデルオブジェクト作成
         $new = Model_Review::forge();
         $new->set($props);
         //データを保存する
         if (!$new->save()) {
             //保存失敗
             $data['save'] = '正しく投稿できませんでした。';
         } else {
             //保存成功
             //$input_title, $input_comment, $input_rating を初期化
             $first['input_title'] = '';
             $first['input_comment'] = '';
             $first['input_rating'] = 5.0;
         }
     }
     //$val->run()ここまで
     //Validationオブジェクトをビューに渡す
     $first['val'] = $val;
     // ********************************
     $first['itta'] = Model_Members_General::countItta($pid);
     $first['ikitai'] = Model_Members_General::countIkitai($pid);
     $first['reviews'] = Model_Members_General::getReviews($pid);
     $first['revnum'] = Model_Members_General::countReview($pid);
     $first['msg'] = $this->msg;
     $this->template->content = View::forge('members/postlookuprev', $first);
 }
开发者ID:akmnhm,项目名称:tabi_log,代码行数:57,代码来源:postlookup.php

示例5: getNewMemberCount

 /**
  * 新規会員数
  *
  * @access private
  * @param
  * @return int
  * @author ida
  */
 private function getNewMemberCount()
 {
     $date = \Date::forge(strtotime('- 1 day'));
     $field = \DB::expr("DATE_FORMAT(created_at, '%Y-%m-%d')");
     $query = \Model_User::query();
     $query->where($field, $date->format('%Y-%m-%d'));
     $count = $query->count();
     return $count;
 }
开发者ID:eva-tuantran,项目名称:use-knife-solo-instead-chef-solo-day13,代码行数:17,代码来源:index.php

示例6: action_index

 /**
  * Demonstrates reading data through an ORM model
  */
 public function action_index()
 {
     $event_model = Model_Orm_Event::find("all", array("where" => array(array('start', '>=', Date::forge()->format("%Y-%m-%d"))), "order_by" => array("start" => "asc"), "related" => array("agendas", "location")));
     $main_content = View::forge("event/index");
     $main_content->set("event_model", $event_model);
     $this->template->libs_js = array("http://code.jquery.com/jquery-1.8.2.js");
     $this->template->page_title = __("ACTION_INDEX_TITLE");
     $this->template->page_content = $main_content;
 }
开发者ID:beingsane,项目名称:TTII_2012,代码行数:12,代码来源:event.php

示例7: action_index

 public function action_index()
 {
     echo '<pre>';
     echo 'FuelPHP version: ' . Fuel::VERSION . "\n";
     echo '			local: ' . setlocale(LC_ALL, '0') . "\n";
     echo '			 date: ' . Date::forge()->format('mysql') . "\n";
     echo 'default_charset: ' . ini_get('default_charset') . "\n";
     echo '<pre>';
 }
开发者ID:nihonLoomba,项目名称:noteshare-,代码行数:9,代码来源:check.php

示例8: run

 /**
  * メールマガジン送信
  *
  * @access public
  * @param int $mail_magazine_id メルマガID
  * @param int $administrator_id 管理者ID
  * @param int $limit 1回で処理する件数
  * @return void
  * @author ida
  */
 public function run($mail_magazine_id, $administrator_id = 0, $limit = 1000)
 {
     $this->openLog($mail_magazine_id);
     $this->log('メルマガID: ' . $mail_magazine_id . ' の送信を開始します' . "\n");
     if (\Model_Mail_Magazine::isProcess()) {
         $this->log('メルマガ送信中のため送信できません' . "\n");
         exit;
     }
     $mail_magazine = \Model_Mail_Magazine::startProcess($mail_magazine_id);
     $offset = 0;
     if (!is_numeric($limit) || $limit <= 0) {
         $limit = 1000;
     }
     $total_count = 0;
     $success_count = 0;
     $fail_count = 0;
     while ($limit > 0) {
         $mail_magazine_users = \Model_Mail_Magazine_User::findByMailMagazineId($mail_magazine_id, $offset, $limit);
         if (count($mail_magazine_users) == 0) {
             break;
         }
         $is_stop = false;
         $replace_data = $this->makeReplaceData($mail_magazine);
         foreach ($mail_magazine_users as $mail_magazine_user) {
             try {
                 usleep(300000);
                 if (!\Model_Mail_Magazine::isProcess($mail_magazine_id)) {
                     $is_stop = true;
                     $this->log($mail_magazine_user->user_id . ": cancel.\n");
                     break;
                 }
                 $send_result = $this->send($mail_magazine_user, $mail_magazine, $replace_data);
                 \Model_Mail_Magazine_User::updateStatus(array('send_status' => $send_result, 'error' => null, 'updated_user' => $administrator_id), array('mail_magazine_user_id' => $mail_magazine_user->mail_magazine_user_id));
                 $this->log($mail_magazine_user->user_id . " : success\n");
                 $success_count++;
             } catch (\Exception $e) {
                 $message = $e->getMessage();
                 $this->log($mail_magazine_user->user_id . ' : fail ' . $message . "\n");
                 \Model_Mail_Magazine_User::updateStatus(array('send_status' => \Model_Mail_Magazine_User::SEND_STATUS_ERROR_END, 'error' => $message, 'updated_user' => $administrator_id), array('mail_magazine_user_id' => $mail_magazine_user->mail_magazine_user_id));
                 $fail_count++;
             }
             $total_count++;
         }
         $offset += $limit;
     }
     $this->log('[total] ' . $total_count . ' [success] ' . $success_count . ' [fail] ' . $fail_count . "\n");
     $this->log('送信を終了しました');
     $this->closeLog();
     $mail_magazine->send_datetime = \Date::forge()->format('mysql');
     if ($is_stop) {
         $mail_magazine->send_status = \Model_Mail_Magazine::SEND_STATUS_CANCEL;
     } else {
         $mail_magazine->send_status = \Model_Mail_Magazine::SEND_STATUS_NORMAL_END;
     }
     $mail_magazine->save();
 }
开发者ID:eva-tuantran,项目名称:use-knife-solo-instead-chef-solo-day13,代码行数:66,代码来源:mail_magazine.php

示例9: _columns

 protected static function _columns()
 {
     $columns = array('id' => array('label' => 'ID', 'grid' => array('visible' => true, 'sortable' => true)), 'name' => array('label' => 'Name', 'grid' => array('process' => function ($data, $value) {
         $prof = unserialize($data->profile_fields);
         return $prof['first_name'] . ' ' . $prof['last_name'];
     })), 'username' => array('label' => 'Username', 'grid' => array('visible' => true, 'sortable' => true)), 'group' => array('label' => 'Group', 'grid' => array('visible' => true, 'sortable' => true, 'process' => function ($data, $value) {
         return static::$groups[$data->group];
     })), 'email' => array('label' => 'Email', 'grid' => array('visible' => true, 'sortable' => false)), 'last_login' => array('label' => 'Last Login', 'grid' => array('visible' => true, 'sortable' => false, 'process' => function ($data, $value) {
         return empty($data->last_login) ? '<span class="label warning">Never</span>' : '<span class="label">' . \Date::forge($data->last_login)->format('%Y-%m-%d %H:%M') . '</span>';
     })), '_action_' => Petro_Grid::default_actions());
     return $columns;
 }
开发者ID:ratiw,项目名称:petro,代码行数:12,代码来源:users.php

示例10: action_index

 public function action_index()
 {
     $pid = 1;
     /* 仮 */
     $uid = 1;
     /* 仮 */
     /* 本当はレビュー投稿したヒトのuid */
     //ビューに渡すデータの配列を初期化
     $data = array();
     if (Input::method() == 'POST') {
         /*--------
           ユーザが入力した値とその時の時刻を保持
           ------*/
         $data['input_title'] = Input::post('title');
         $data['input_comment'] = Input::post('comment');
         $data['input_rating'] = Input::post('rating');
         $time = Date::forge()->get_timestamp();
     }
     /*-----------
       Validationの準備
       -----------*/
     //Validationオブジェクトを呼び出す
     $val = Validation::forge();
     //フォームのルール設定
     $val->add('title', 'タイトル')->add_rule('required')->add_rule('max_length', 30);
     $val->add('comment', 'コメント')->add_rule('required');
     //コメントの長さ制限いる?
     $val->add('rating', '評価')->add_rule('required');
     //Validationチェック
     if ($val->run()) {
         /*------------
            postされた各データをDBに保存
           ----------------*/
         $props = array('uid' => $uid, 'pid' => $pid, 'title' => $data['input_title'], 'comment' => $data['input_comment'], 'rating' => $data['input_rating'], 'datetime' => $time);
         //モデルオブジェクト作成
         $new = Model_Review::forge($props);
         //データを保存する
         if (!$new->save()) {
             //保存失敗
             $data['save'] = '正しく投稿できませんでした。';
         } else {
             //保存成功
             /* 本当はルックアップページのレビュー画面に飛びたい */
             Response::redirect('members/top');
         }
     }
     //$val->run()ここまで
     //Validationオブジェクトをビューに渡す
     $data['val'] = $val;
     return View::forge('members/review', $data, false);
 }
开发者ID:akmnhm,项目名称:tabi_log,代码行数:51,代码来源:review_matsuharu.php

示例11: action_index

 public function action_index()
 {
     echo '<pre>';
     echo Fuel::VERSION . "\n";
     echo setlocale(LC_ALL, '') . "\n";
     echo Date::forge()->format('mysql') . "\n";
     echo ini_get('default_charset') . "\n";
     echo '</pre>';
     $cd = '10001';
     $result = Model_Employee::find_by_cd($cd);
     foreach ($result->as_array() as $row) {
         echo $row['lname'] . "\n";
         echo $row['fname'] . "\n";
     }
     echo count($result);
 }
开发者ID:RyuichiMakishita,项目名称:web_app,代码行数:16,代码来源:check.php

示例12: check_and_create

 public static function check_and_create($foreign_table, $foreign_id, $type)
 {
     $since_datetime = \Date::forge(strtotime('-' . \Config::get('notice.periode_to_update.default')))->format('mysql');
     if (!($obj = self::get_last4foreign_data($foreign_table, $foreign_id, $type, $since_datetime))) {
         $obj = self::forge(array('foreign_table' => $foreign_table, 'foreign_id' => $foreign_id, 'type' => $type, 'body' => Site_Util::get_notice_body($foreign_table, $type)));
         if (!in_array($foreign_table, Site_Util::get_accept_parent_tables()) && ($parent_table = \Site_Model::get_parent_table($foreign_table))) {
             $obj->parent_table = $parent_table;
             $foreign_obj_name = \Site_Model::get_model_name($foreign_table);
             $foreign_obj = $foreign_obj_name::find($foreign_id);
             $parent_id_prop = $parent_table . '_id';
             $obj->parent_id = $foreign_obj->{$parent_id_prop};
         }
         $obj->save();
     }
     return $obj;
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:16,代码来源:notice.php

示例13: up

 /**
  * Create tables: users, options, posts, tags, posts_tags
  */
 public function up()
 {
     \DBUtil::create_table('users', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'username' => array('type' => 'varchar', 'constraint' => 50), 'password' => array('type' => 'varchar', 'constraint' => 256), 'group' => array('type' => 'int', 'constraint' => 11, 'default' => 1), 'email' => array('type' => 'varchar', 'constraint' => 256), 'last_login' => array('type' => 'varchar', 'constraint' => 25), 'login_hash' => array('type' => 'varchar', 'constraint' => 256), 'profile_fields' => array('type' => 'text')), array('id'));
     // Coming soon
     // \DBUtil::create_index('users', 'username', 'unique');
     // \DBUtil::create_index('users', 'email', 'unique');
     \DBUtil::create_table('options', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'option' => array('type' => 'varchar', 'constraint' => 128), 'value' => array('type' => 'text')), array('id'));
     // Coming soon
     // \DBUtil::create_index('options', 'option', 'unique');
     \DBUtil::create_table('posts', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'user_id' => array('type' => 'int', 'constraint' => 11), 'title' => array('type' => 'varchar', 'constraint' => 128), 'slug' => array('type' => 'varchar', 'constraint' => 128), 'body' => array('type' => 'text'), 'created_at' => array('type' => 'datetime'), 'updated_at' => array('type' => 'datetime')), array('id'));
     // Coming soon
     // \DBUtil::create_index('posts', 'slug', 'unique');
     \DBUtil::create_table('tags', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'tag' => array('type' => 'varchar', 'constraint' => 128), 'slug' => array('type' => 'varchar', 'constraint' => 128)), array('id'));
     // Coming soon
     // \DBUtil::create_index('tags', 'tag', 'unique');
     // \DBUtil::create_index('tags', 'slug', 'unique');
     \DBUtil::create_table('posts_tags', array('post_id' => array('type' => 'int', 'constraint' => 11), 'tag_id' => array('type' => 'int', 'constraint' => 11)));
     \Auth::create_user('admin', 'admin', 'admin@example.com', 100);
     \Option::reset();
     \DB::insert('posts')->columns(array('user_id', 'title', 'slug', 'body', 'created_at', 'updated_at'))->values(array(1, 'My first post', 'my-first-post', 'This is my first post. Yiharr!', \Date::forge()->format('mysql'), \Date::forge()->format('mysql')))->execute();
     \DB::insert('tags')->columns(array('tag', 'slug'))->values(array('My first tag', 'my-first-tag'))->execute();
     \DB::insert('posts_tags')->columns(array('post_id', 'tag_id'))->values(array(1, 1))->execute();
 }
开发者ID:hfroemmel,项目名称:populu,代码行数:26,代码来源:001_populu.php

示例14: type_time_decode

 /**
  * Takes a DB timestamp and converts it into a Date object
  *
  * @param   string  value
  * @param   array  any options to be passed
  *
  * @return  \Fuel\Core\Date
  */
 public static function type_time_decode($var, array $settings)
 {
     if ($settings['data_type'] == 'time_mysql') {
         // deal with a 'nulled' date, which according to MySQL is a valid enough to store?
         if ($var == '0000-00-00 00:00:00') {
             if (array_key_exists('null', $settings) and $settings['null'] === false) {
                 throw new InvalidContentType('Value ' . $var . ' is not a valid date and can not be converted to a Date object.');
             }
             return null;
         }
         return \Date::create_from_string($var, 'mysql');
     }
     return \Date::forge($var);
 }
开发者ID:takawasitobi,项目名称:pembit,代码行数:22,代码来源:typing.php

示例15: update_user

 /**
  * Update a user's properties
  * Note: Username cannot be updated, to update password the old password must be passed as old_password
  *
  * @param   Array  properties to be updated including profile fields
  * @param   string
  * @return  bool
  */
 public function update_user($values, $username = null)
 {
     $username = $username ?: $this->user['username'];
     $current_values = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))->where('username', '=', $username)->from(\Config::get('simpleauth.table_name'))->execute(\Config::get('simpleauth.db_connection'));
     if (empty($current_values)) {
         throw new \SimpleUserUpdateException('Username not found', 4);
     }
     $update = array();
     if (array_key_exists('username', $values)) {
         throw new \SimpleUserUpdateException('Username cannot be changed.', 5);
     }
     if (array_key_exists('password', $values)) {
         if (empty($values['old_password']) or $current_values->get('password') != $this->hash_password(trim($values['old_password']))) {
             throw new \SimpleUserWrongPassword('Old password is invalid');
         }
         $password = trim(strval($values['password']));
         if ($password === '') {
             throw new \SimpleUserUpdateException('Password can\'t be empty.', 6);
         }
         $update['password'] = $this->hash_password($password);
         unset($values['password']);
     }
     if (array_key_exists('old_password', $values)) {
         unset($values['old_password']);
     }
     if (array_key_exists('email', $values)) {
         $email = filter_var(trim($values['email']), FILTER_VALIDATE_EMAIL);
         if (!$email) {
             throw new \SimpleUserUpdateException('Email address is not valid', 7);
         }
         $update['email'] = $email;
         unset($values['email']);
     }
     if (array_key_exists('group', $values)) {
         if (is_numeric($values['group'])) {
             $update['group'] = (int) $values['group'];
         }
         unset($values['group']);
     }
     if (!empty($values)) {
         $profile_fields = @unserialize($current_values->get('profile_fields')) ?: array();
         foreach ($values as $key => $val) {
             if ($val === null) {
                 unset($profile_fields[$key]);
             } else {
                 $profile_fields[$key] = $val;
             }
         }
         $update['profile_fields'] = serialize($profile_fields);
     }
     $update['updated_at'] = \Date::forge()->get_timestamp();
     $affected_rows = \DB::update(\Config::get('simpleauth.table_name'))->set($update)->where('username', '=', $username)->execute(\Config::get('simpleauth.db_connection'));
     // Refresh user
     if ($this->user['username'] == $username) {
         $this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))->where('username', '=', $username)->from(\Config::get('simpleauth.table_name'))->execute(\Config::get('simpleauth.db_connection'))->current();
     }
     return $affected_rows > 0;
 }
开发者ID:unagiya,项目名称:FuelPHP_1_7_CustomAuth,代码行数:66,代码来源:simpleauth.php


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