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


PHP Inflector::length方法代码示例

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


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

示例1: insert

 private function insert(array $data)
 {
     $id = $data['id'];
     foreach ($data as $k => $v) {
         if ($k == 'id') {
             continue;
         }
         $motor = 'string';
         if (fnmatch('*_id', $k)) {
             $motor = 'int';
             $v = (int) $v;
         } elseif (is_numeric($v)) {
             if (fnmatch('*.*', $v) || fnmatch('*.*', $v)) {
                 $motor = 'float';
                 $v = (double) $v;
             } else {
                 $motor = 'int';
                 $v = (int) $v;
             }
         } else {
             if (!is_string($v)) {
                 throw new Exception("An error occured to save this model. Please check the values.");
             }
             $length = Inflector::length($v);
             $motor = 255 < $length ? 'text' : 'string';
         }
         $fieldRow = $motor . '_value';
         $row = lib('mysql', 'kvdatas')->where('object_database', '=', $this->db)->where('object_table', '=', $this->table)->where('object_field', '=', $k)->where('object_id', '=', $id)->first();
         if ($row) {
             $row->{$fieldRow} = $v;
             $row->save();
         } else {
             lib('mysql', 'kvdatas')->create(['object_database' => $this->db, 'object_table' => $this->table, 'object_field' => $k, 'object_id' => $id, $fieldRow => $v]);
         }
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:36,代码来源:Db.php

示例2: getToken

 public static function getToken($clientId, $clientSecret, $environment = 'development')
 {
     $url = 'development' == $environment ? 'https://api.sandbox.paypal.com/v1/oauth2/token' : 'https://api.paypal.com/v1/oauth2/token';
     $auth = $clientId . ':' . $clientSecret;
     $ch = curl_init();
     $postData = "grant_type=client_credentials";
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_PORT, 443);
     curl_setopt($ch, CURLOPT_VERBOSE, 0);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json", "Accept-Language: en_US", "Content-length: " . Inflector::length($postData)));
     curl_setopt($ch, CURLOPT_USERPWD, $auth);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
     $data = json_decode(curl_exec($ch), true);
     curl_close($ch);
     return $data['access_token'];
 }
开发者ID:schpill,项目名称:thin,代码行数:24,代码来源:Paypal.php


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