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


PHP aql::now方法代码示例

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


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

示例1: saveArray

 /**
  * aql::insert/update on the save array depending on what needs to be done
  * recursive because of sub objects / queries
  * @param   array   $save_array     array to save
  * @param   array   $ids            ids to pass through
  * @return  array                   updated save array
  */
 private final function saveArray($save_array, $ids = array())
 {
     $is_dev = $this->isDev();
     // copy out objects
     $objects = $save_array['__objects__'];
     unset($save_array['__objects__']);
     // helper function
     $addRecordInfo = function ($table_block, $is_update = false) {
         $fields = array('update' => array('mod__person_id', 'update__person_id'), 'insert' => array('insert__person_id'));
         $key = $is_update ? 'update' : 'insert';
         $time_field = $key . '_time';
         if (!$table_block['fields'][$time_field]) {
             $table_block['fields'][$time_field] = aql::now();
         }
         if (!defined('PERSON_ID') || !is_numeric(PERSON_ID)) {
             return $table_block;
         }
         $id = PERSON_ID;
         $fields = $fields[$key];
         foreach ($fields as $field) {
             $table_block['fields'][$field] = $table_block['fields'][$field] ?: $id;
         }
         return $table_block;
     };
     foreach ($save_array as $table => $info) {
         // make sure this is an array
         $info['fields'] = arrayify($info['fields']);
         foreach ($ids as $n => $v) {
             if (is_array($this->_ignore['fields']) && in_array($n, $this->_ignore['fields'])) {
                 // since ids are added to each table in case of foreign keys
                 // abort if they are being ignored in this model
                 continue;
             }
             // add the id to the table block iff there are already fields
             if ($info['fields'] && !$info['fields'][$n]) {
                 $save_array[$table]['fields'][$n] = $v;
                 $info['fields'][$n] = $v;
             }
         }
         if ($info['fields']) {
             $is_update = $info['id'] && is_numeric($info['id']);
             $info = $addRecordInfo($info, $is_update);
             if ($is_update) {
                 aql::update($table, $info['fields'], $info['id'], true);
             } else {
                 $rs = aql::insert($table, $info['fields'], true);
                 $save_array[$table]['id'] = $info['id'] = $rs[0][$table . '_id'];
             }
         }
         $ids[$table . '_id'] = $info['id'];
         if (is_array($info['subs'])) {
             foreach ($info['subs'] as $i => $sub) {
                 $save_array[$table]['subs'][$i] = $this->saveArray($sub, $ids);
             }
         }
     }
     if (is_array($objects)) {
         foreach ($objects as $o) {
             if (!$o['data']) {
                 continue;
             }
             $tmp = Model::get($o['object']);
             $tmp->_data = $o['data'];
             $tmp->loadIDs($ids);
             $pt = $tmp->getPrimaryTable();
             $pt_id = $pt . '_id';
             if (!$tmp->{$pt_id} && $this->{$pt_id}) {
                 $tmp->{$pt_id} = $this->{$pt_id};
             }
             $tmp->save(true);
             if ($tmp->_errors) {
                 $this->addErrors($tmp->_errors);
                 $this->failTransaction();
             }
         }
     }
     $save_array['objects'] = $objects;
     return $save_array;
 }
开发者ID:HotwireCommunications,项目名称:skyphp,代码行数:86,代码来源:class.Model.php

示例2: getOAuthToken

 /**
  * Get or create a token for this person_id for this app
  * @return  array
  */
 public function getOAuthToken()
 {
     $person_id = $this->person_id();
     if (!$person_id) {
         static::error('User not specified.');
     }
     if (!\person::exists($person_id)) {
         static::error('Invalid user.');
     }
     $clause = array('person_id' => $person_id);
     if (!$this->app_key()) {
         $app_id = null;
     } else {
         $api_app = static::getApiAppByKey($this->app_key());
         if (!$api_app) {
             static::error('Invalid app_key.');
         }
         $app_id = $api_app->getID();
     }
     $clause[static::getApiAppModelName() . '_id'] = $app_id;
     if (!$clause) {
         static::error('Unknown Identity.');
     }
     $m = static::getOauthModelName();
     $oauth = $m::getOne($clause);
     if (!$oauth || !$oauth->token) {
         $oauth = $m::insert($clause);
     }
     return array('oauth_token' => $oauth->token, 'issued' => $oauth->getTimeIssued(), 'now' => strtotime(\aql::now()), 'expires' => $oauth->getTimeExpires());
 }
开发者ID:HotwireCommunications,项目名称:skyphp,代码行数:34,代码来源:Identity.php


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