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


PHP Arrays::is方法代码示例

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


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

示例1: __construct

 public function __construct($table, $fields)
 {
     /* polymorphism */
     $fields = !Arrays::is($fields) ? strstr($fields, ',') ? explode(',', repl(' ', '', $fields)) : [$fields] : $fields;
     $this->table = $table;
     $this->fields = $fields;
 }
开发者ID:schpill,项目名称:standalone,代码行数:7,代码来源:Indexation.php

示例2: __construct

 /**
  * Creates a new navigation container
  *
  * @param array $pages  [optional] pages to add
  * @throws Exception    if $pages is invalid
  */
 public function __construct($pages = null)
 {
     if (Arrays::is($pages)) {
         $this->addPages($pages);
     } elseif (null !== $pages) {
         throw new Exception('Invalid argument: $pages must be an array or null');
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:14,代码来源:Navigation.php

示例3: where

 /**
  * where()
  * Sets where object
  * @access public
  * @param string $where
  * @param string $value
  * @return \Thin\Webquery
  */
 public function where($where = null, $value = null)
 {
     if (Arrays::is($this->where)) {
         $this->whereKey = count($this->where) + 1;
     }
     $this->where[$this->whereKey]['attr'] = $where;
     $this->where[$this->whereKey]['value'] = $value;
     return $this;
 }
开发者ID:schpill,项目名称:thin,代码行数:17,代码来源:Webquery.php

示例4: __construct

 /**
  * Construct new RangeQuery component
  *
  * @return \ElasticSearch\DSL\RangeQuery
  * @param array $options
  */
 public function __construct(array $options = [])
 {
     $this->fieldname = key($options);
     $values = Arrays::first($options);
     if (Arrays::is($values)) {
         foreach ($values as $key => $val) {
             $this->{$key} = $val;
         }
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:16,代码来源:RangeQuery.php

示例5: config

 /**
  * Get or set a config
  *
  * @param string $key
  * @param mixed $value
  * @throws \Exception
  * @return array|void
  */
 public function config($key, $value = null)
 {
     if (Arrays::is($key)) {
         $this->config = $key + $this->config;
     } else {
         if ($value !== null) {
             $this->config[$key] = $value;
         }
         if (!isset($this->config[$key])) {
             throw new Exception("Configuration key `type` is not set");
         }
         return $this->config[$key];
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:22,代码来源:Mapping.php

示例6: arrayReplaceRecursive

 /**
  * Custom arrayReplaceRecursive to be used if PHP < 5.3
  * Replaces elements from passed arrays into the first array recursively
  *
  * @param array $array1 The array in which elements are replaced
  * @param array $array2 The array from which elements will be extracted
  *
  * @return array Returns an array, or NULL if an error occurs.
  */
 public static function arrayReplaceRecursive($array1, $array2)
 {
     if (function_exists('arrayReplaceRecursive')) {
         return arrayReplaceRecursive($array1, $array2);
     }
     foreach ($array2 as $key => $value) {
         if (Arrays::is($value)) {
             $array1[$key] = self::arrayReplaceRecursive($array1[$key], $value);
         } else {
             $array1[$key] = $value;
         }
     }
     return $array1;
 }
开发者ID:schpill,项目名称:standalone,代码行数:23,代码来源:Mysqldump.php

示例7: add

 /**
  * Add a model item or model array or ModelSet to this set
  *
  * @param mixed $items model item or arry or ModelSet to add
  *
  * @return $this
  */
 public function add($items)
 {
     if ($items && $items instanceof Container) {
         $id = (int) $items->id();
         $this->_items[$id] = $items;
     } elseif (Arrays::is($items)) {
         foreach ($items as $obj) {
             if ($obj instanceof Container) {
                 $this->add($obj);
             }
         }
     } elseif ($items instanceof self) {
         $this->add($items->toArray());
     }
     return $this;
 }
开发者ID:noikiy,项目名称:inovi,代码行数:23,代码来源:Collection.php

示例8: query

 public function query($query, $meta = [])
 {
     $q = json_encode($query);
     $q = urlencode($q);
     $url = $this->uri . '/db/' . $this->db . '/collection/' . $this->col . '/apiKey/' . $this->apiKey . '/query/' . $q;
     if (!empty($meta)) {
         $mv = [];
         foreach ($meta as $k => $v) {
             if (Arrays::is($v)) {
                 $v = json_encode($v);
             }
             $mv[] = $k . '=' . $v;
         }
         $mv = implode('&', $mv);
         $url .= '&' . $mv;
     }
     $ret = $this->request->get($url);
     return json_decode($ret, true);
 }
开发者ID:schpill,项目名称:standalone,代码行数:19,代码来源:Client.php

示例9: build

 /**
  * Build the DSL as array
  *
  * @throws \ElasticSearch\Exception
  * @return array
  */
 public function build()
 {
     $built = [];
     if ($this->from != null) {
         $built['from'] = $this->from;
     }
     if ($this->size != null) {
         $built['size'] = $this->size;
     }
     if ($this->sort && Arrays::is($this->sort)) {
         $built['sort'] = $this->sort;
     }
     if (!$this->query) {
         throw new \ElasticSearch\Exception("Query must be specified");
     } else {
         $built['query'] = $this->query->build();
     }
     return $built;
 }
开发者ID:schpill,项目名称:standalone,代码行数:25,代码来源:Builder.php

示例10: search

 /**
  * Search
  *
  * @return array
  * @param array|string $query
  * @throws \ElasticSearch\Exception
  */
 public function search($query)
 {
     if (Arrays::is($query)) {
         if (Arrays::exists("query", $query)) {
             $dsl = new Stringify($query);
             $q = (string) $dsl;
             $url = $this->buildUrl(array($this->type, "_search?q=" . $q));
             $result = json_decode(redis()->get($url), true);
             return $result;
         }
         throw new \ElasticSearch\Exception("Redis protocol doesn t support the full DSL, only query");
     } elseif (is_string($query)) {
         /**
          * String based search means http query string search
          */
         $url = $this->buildUrl(array($this->type, '_search?q=' . $query));
         $result = json_decode(redis()->get($url), true);
         return $result;
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:27,代码来源:Redis.php

示例11: make

 public static function make($db, $what)
 {
     if (is_string($what)) {
         $file = APPLICATION_PATH . DS . 'models' . DS . 'Bigdata' . DS . 'views' . DS . $db->db . DS . ucfirst(I::lower($db->table)) . DS . I::camelize($what) . '.php';
         if (files()->exists($file)) {
             require_once $file;
             $class = '\\Thin\\' . ucfirst(I::lower($db->db)) . ucfirst(I::lower($db->table)) . 'View';
             return $class::make($db);
         } else {
             return $db;
         }
     } elseif (A::is($what)) {
         $nameview = 'view_' . $db->db . '_' . $db->table . '_' . sha1(serialize($what));
         $ageDb = $db->getage();
         $viewDb = Db::instance($db->db, $nameview);
         $ageView = $db->getage();
         $exists = strlen($db->cache()->get('dbRedis.views.' . $nameview)) ? true : false;
         if ($ageView < $ageDb || !$exists) {
             $viewDb->getCollection()->remove();
             foreach ($what as $wh) {
                 $op = 'AND';
                 if (count($wh) == 4) {
                     $op = $wh[3];
                     unset($wh[3]);
                 }
                 $db = $db->where($wh);
             }
             $res = $db->exec();
             foreach ($res as $row) {
                 $viewDb->saveView($row);
             }
             $db->cache()->set('dbRedis.views.' . $nameview, 1);
         }
         return $viewDb;
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:36,代码来源:View.php

示例12: order

 public function order($fieldOrder = 'date_create', $orderDirection = 'ASC', $results = array())
 {
     $res = count($results) ? $results : $this->results;
     $fields = $this->fields;
     $fields['id'] = array();
     $fields['date_create'] = array();
     if (!Arrays::is($fieldOrder)) {
         if (null !== $fieldOrder && !Arrays::exists($fieldOrder, $fields)) {
             $fields[$fieldOrder] = array();
         }
     } else {
         foreach ($fields as $tmpField => $info) {
             if (null !== $tmpField && !Arrays::exists($tmpField, $fields)) {
                 $fields[$tmpField] = array();
             }
         }
     }
     $sort = array();
     foreach ($res as $id) {
         $objectCreated = $this->row($id);
         foreach ($fields as $key => $infos) {
             $type = Arrays::exists('type', $fields[$key]) ? $fields[$key]['type'] : null;
             if ('data' == $type) {
                 list($dummy, $foreignTable, $foreignFieldKey) = $fields[$key]['contentList'];
                 $foreignFields = Arrays::exists($foreignTable, Data::$_fields) ? Data::$_fields[$foreignTable] : Data::noConfigFields($foreignTable);
                 $foreignStorage = new self($foreignTable);
                 $foreignRow = $foreignStorage->find($objectCreated->{$key});
                 $foreignFieldKeys = explode(',', $foreignFieldKey);
                 $value = '';
                 for ($i = 0; $i < count($foreignFieldKey); $i++) {
                     $tmpKey = $foreignFieldKey[$i];
                     $value .= $foreignRow->{$tmpKey} . ' ';
                 }
                 $value = substr($value, 0, -1);
             } else {
                 $value = isset($objectCreated->{$key}) ? $objectCreated->{$key} : null;
             }
             $sort[$key][] = $value;
         }
     }
     $asort = array();
     foreach ($sort as $key => $rows) {
         for ($i = 0; $i < count($rows); $i++) {
             if (empty(${$key}) || is_string(${$key})) {
                 ${$key} = array();
             }
             $asort[$i][$key] = $rows[$i];
             array_push(${$key}, $rows[$i]);
         }
     }
     if (Arrays::is($fieldOrder) && !Arrays::is($orderDirection)) {
         $t = array();
         foreach ($fieldOrder as $tmpField) {
             array_push($t, $orderDirection);
         }
         $orderDirection = $t;
     }
     if (Arrays::is($fieldOrder) && Arrays::is($orderDirection)) {
         if (count($orderDirection) < count($fieldOrder)) {
             throw new Exception('You must provide the same arguments number of fields sorting and directions sorting.');
         }
         if (count($fieldOrder) == 1) {
             $fieldOrder = Arrays::first($fieldOrder);
             if ('ASC' == Inflector::upper(Arrays::first($orderDirection))) {
                 array_multisort(${$fieldOrder}, SORT_ASC, $asort);
             } else {
                 array_multisort(${$fieldOrder}, SORT_DESC, $asort);
             }
         } elseif (count($fieldOrder) > 1) {
             $params = array();
             foreach ($fieldOrder as $k => $tmpField) {
                 $tmpSort = isset($orderDirection[$k]) ? $orderDirection[$k] : 'ASC';
                 $params[] = ${$tmpField};
                 $params[] = 'ASC' == $tmpSort ? SORT_ASC : SORT_DESC;
             }
             $params[] = $asort;
             call_user_func_array('array_multisort', $params);
         }
     } else {
         if ('ASC' == Inflector::upper($orderDirection)) {
             array_multisort(${$fieldOrder}, SORT_ASC, $asort);
         } else {
             array_multisort(${$fieldOrder}, SORT_DESC, $asort);
         }
     }
     $collection = array();
     foreach ($asort as $key => $row) {
         $tmpId = $row['id'];
         array_push($collection, $tmpId);
     }
     $this->results = $collection;
     return $this;
 }
开发者ID:schpill,项目名称:thin,代码行数:93,代码来源:Store.php

示例13: keep

 public function keep($keys, $returnCollection = true)
 {
     /* polymorphism */
     $keys = !Arrays::is($keys) ? strstr($keys, ',') ? explode(',', repl(' ', '', $keys)) : [$keys] : $keys;
     $results = [];
     if (count($this->_items)) {
         foreach ($this->_items as $item) {
             $value = [];
             foreach ($keys as $key) {
                 array_push($value, isAke($item, $key, null));
             }
             array_push($results, implode(' ', $value));
         }
     }
     return true === $returnCollection ? new self($results) : $results;
 }
开发者ID:schpill,项目名称:standalone,代码行数:16,代码来源:Collection.php

示例14: toArray

 /**
  * Export datas to array
  *
  * @param array $ignore ignore
  * @param bool $recursive
  * @param int $deep
  *
  * @return array
  */
 public function toArray($ignore = array('_type'), $recursive = false, $deep = 3)
 {
     if (!empty($ignore)) {
         $ignores = array();
         foreach ($ignore as $val) {
             $ignores[$val] = 1;
         }
         $ignore = $ignores;
     }
     if ($recursive == true && $deep > 0) {
         $attrs = $this->getAttrs();
         foreach ($this->cleanData as $key => $value) {
             if (isset($attrs[$key]) && isset($attrs[$key]['type']) && ($attrs[$key]['type'] == self::DATA_TYPE_REFERENCE || $attrs[$key]['type'] == self::DATA_TYPE_REFERENCES)) {
                 if ($attrs[$key]['type'] == self::DATA_TYPE_REFERENCE && isset($attrs[$key]['model']) && !empty($attrs[$key]['model'])) {
                     $model = $attrs[$key]['model'];
                     if (!is_array($value)) {
                         $value = (array) $value;
                     }
                     $obj = $model::id($value['$id']);
                     if ($obj) {
                         $this->cleanData[$key] = $obj->toArray($ignore, $recursive, --$deep);
                     }
                 } else {
                     if ($attrs[$key]['type'] == self::DATA_TYPE_REFERENCES && isset($attrs[$key]['model']) && !empty($attrs[$key]['model'])) {
                         $model = $attrs[$key]['model'];
                         $data = array();
                         foreach ($value as $item) {
                             if (!\Thin\Arrays::is($item)) {
                                 $item = (array) $item;
                             }
                             $obj = $model::id($item['$id']);
                             if ($obj) {
                                 $data[] = $obj->toArray($ignore, $recursive, --$deep);
                             }
                         }
                         if (!empty($data)) {
                             $this->cleanData[$key] = $data;
                         }
                     }
                 }
             }
         }
     }
     return array_diff_key($this->cleanData, $ignore);
 }
开发者ID:noikiy,项目名称:inovi,代码行数:54,代码来源:Model.php

示例15: populate

 public function populate(array $datas, $namespace = null)
 {
     if (null !== $namespace) {
         if (!isset($this->{$namespace})) {
             $this->{$namespace} = [];
         }
         foreach ($datas as $k => $v) {
             if (Arrays::is($k)) {
                 $this->populate($k, $namespace);
             } else {
                 $this->{$namespace} = array_merge($this->{$namespace}, [$k => $v]);
             }
         }
     } else {
         foreach ($datas as $k => $v) {
             $id = isAke($datas, 'id', false);
             if (Arrays::is($v) && false === $id) {
                 if (Arrays::isAssoc($v)) {
                     $o = new self();
                     $o->populate($v);
                     $this->{$k} = $o;
                 } else {
                     $this->{$k} = $v;
                 }
             } else {
                 $this->{$k} = $v;
             }
             if (!Arrays::in($k, $this->_fields)) {
                 $this->_fields[] = $k;
             }
         }
     }
     return $this;
 }
开发者ID:schpill,项目名称:thin,代码行数:34,代码来源:Object.php


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