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


PHP Data::getById方法代码示例

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


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

示例1: save

 public function save()
 {
     $edit = array();
     $edit['expire'] = time() + $this->_duration;
     $edit['session_name'] = $this->_sessionName;
     $edit['session_key'] = $this->_key;
     $edit['data'] = $this->_session->getData();
     $id = parent::edit('thinsession', $this->_session->getId(), $edit);
     $this->_session = parent::getById('thinsession', $id);
     $data = $this->_session->getData();
     return $data;
 }
开发者ID:schpill,项目名称:thin,代码行数:12,代码来源:Sessionbis.php

示例2: save

 public static function save($id)
 {
     $res = Data::query('movie', 'id_ac = ' . $id);
     if (!count($res)) {
         $info = static::getInfosMovie($id);
         $info['id_ac'] = $id;
         $info['id_video'] = null;
         $info['plateforme'] = null;
         $movie = Data::getById('movie', Data::add('movie', $info));
     } else {
         $movie = Data::getObject(current($res));
     }
     return $movie;
 }
开发者ID:schpill,项目名称:thin,代码行数:14,代码来源:Allocine.php

示例3: getAds

 public function getAds($maxPages = 0)
 {
     set_time_limit(0);
     $first = dwn('http://m.duproprio.com/resultats?hash=/s-pmin=0/s-pmax=99999999/p-ord=date/p-dir=DESC/pa-ge=1/s-filter=forsale/s-build=1/p-con=main/g-pr=1/s-bmin=0');
     $nbPages = 0 == $maxPages ? Utils::cut('Page 1 de ', ' ', $first) : $maxPages;
     $ids = array();
     $infos = array();
     $pageIds = array();
     $tab = explode('<a id=', $first);
     for ($i = 1; $i < count($tab); $i++) {
         $seg = trim($tab[$i]);
         $id = Utils::cut('"', '"', $seg);
         if (!Arrays::in($id, $ids)) {
             array_push($ids, $id);
             array_push($pageIds, $id);
         }
     }
     foreach ($pageIds as $id) {
         $seg = $this->tag('<div class="thumbnail" data-listing-code="' . $id . '">', '<a id="', $first);
         if (!empty($seg)) {
             $tmp = $this->tag('<img src="', '"', $seg);
             $picId = $this->tag('-big-', '.', $tmp);
             $infos[$id]['thumb'] = $picId;
             $type = $this->tag('<span class="listing-type">', '</span>', $seg);
             $type = html_entity_decode(repl(array("\n", "\r", "\t"), '', strip_tags($type)));
             if (contain(',', $type)) {
                 list($type, $bedroom) = explode(',', $type, 2);
             } else {
                 $type = $type;
                 $bedroom = 0;
             }
             $infos[$id]['type'] = $this->clean($type);
             $infos[$id]['bedroom'] = repl(' ch.', '', $this->clean($bedroom));
             $address = $this->tag('<span class="listing-address">', '</span>', $seg);
             $address = html_entity_decode(repl(array("\n", "\r", "\t"), '', strip_tags($address)));
             $address = $this->clean($address);
             $tabAddress = explode(', ', $address);
             if (count($tabAddress)) {
                 $city = Arrays::last($tabAddress);
                 $address = repl(', ' . $city, '', $address);
             } else {
                 $city = '';
             }
             $infos[$id]['address'] = $address;
             $infos[$id]['city'] = $city;
             $price = $this->tag('<span class="listing-price">', '</span>', $seg);
             $price = html_entity_decode(repl(array("\n", "\r", "\t"), '', strip_tags($price)));
             $infos[$id]['price'] = $this->clean(repl(array(' ', '$'), '', $price));
             $infos[$id]['partner'] = 'duproprio';
             $infos[$id]['partner_id'] = $id;
         }
     }
     foreach ($infos as $id => $property) {
         Data::getById('property', Data::add('propriete', $property));
     }
     for ($j = 2; $j <= (int) $nbPages; $j++) {
         $page = dwn('http://m.duproprio.com/resultats?page=' . $j . '&hash=%2Fs-pmin%3D0%2Fs-pmax%3D99999999%2Fp-ord%3Ddate%2Fp-dir%3DDESC%2Fpa-ge%3D2%2Fs-filter%3Dforsale%2Fs-build%3D1%2Fp-con%3Dmain%2Fg-pr%3D1%2Fs-bmin%3D0');
         $infos = array();
         $pageIds = array();
         $tab = explode('<a id=', $page);
         for ($i = 1; $i < count($tab); $i++) {
             $seg = trim($tab[$i]);
             $id = Utils::cut('"', '"', $seg);
             if (!Arrays::in($id, $ids)) {
                 array_push($ids, $id);
                 array_push($pageIds, $id);
             }
         }
         foreach ($pageIds as $id) {
             $seg = $this->tag('<div class="thumbnail" data-listing-code="' . $id . '">', '<a id="', $page);
             if (!empty($seg)) {
                 $tmp = $this->tag('<img src="', '"', $seg);
                 $picId = $this->tag('-big-', '.', $tmp);
                 $infos[$id]['thumb'] = $picId;
                 $type = $this->tag('<span class="listing-type">', '</span>', $seg);
                 $type = html_entity_decode(repl(array("\n", "\r", "\t"), '', strip_tags($type)));
                 if (contain(',', $type)) {
                     list($type, $bedroom) = explode(',', $type, 2);
                 } else {
                     $type = $type;
                     $bedroom = 0;
                 }
                 $infos[$id]['type'] = $this->clean($type);
                 $infos[$id]['bedroom'] = repl(' ch.', '', $this->clean($bedroom));
                 $address = $this->tag('<span class="listing-address">', '</span>', $seg);
                 $address = html_entity_decode(repl(array("\n", "\r", "\t"), '', strip_tags($address)));
                 $address = $this->clean($address);
                 $tabAddress = explode(', ', $address);
                 if (count($tabAddress)) {
                     $city = Arrays::last($tabAddress);
                     $address = repl(', ' . $city, '', $address);
                 } else {
                     $city = '';
                 }
                 $infos[$id]['address'] = $address;
                 $infos[$id]['city'] = $city;
                 $price = $this->tag('<span class="listing-price">', '</span>', $seg);
                 $price = html_entity_decode(repl(array("\n", "\r", "\t"), '', strip_tags($price)));
                 $infos[$id]['price'] = $this->clean(repl(array(' ', '$'), '', $price));
                 $infos[$id]['partner'] = 'duproprio';
//.........这里部分代码省略.........
开发者ID:schpill,项目名称:thin,代码行数:101,代码来源:Duproprio.php

示例4: get

 public function get($results = null)
 {
     $resultsGet = null !== $results ? $results : $this->results;
     $queryKey = sha1(serialize($this->wheres) . serialize($resultsGet));
     $cache = Data::cache($this->type, $queryKey);
     if (!empty($cache) && true === $this->cache) {
         return $cache;
     }
     if (count($resultsGet)) {
         if (null !== $this->groupBy) {
             $groupBys = array();
             $ever = array();
             foreach ($resultsGet as $key => $id) {
                 $object = Data::getById($this->type, $id);
                 $getter = getter($this->groupBy);
                 $obj = $object->{$getter}();
                 if ($obj instanceof Container) {
                     $obj = $obj->getId();
                 }
                 if (!Arrays::in($obj, $ever)) {
                     $groupBys[$key] = $id;
                     $ever[] = $obj;
                 }
             }
             $this->results = $groupBys;
             $this->order($this->groupBy);
             $resultsGet = $this->results;
         }
         if (0 < $this->limit) {
             $max = count($resultsGet);
             $number = $this->limit - $this->offset;
             if ($number > $max) {
                 $this->offset = $max - $this->limit;
                 if (0 > $this->offset) {
                     $this->offset = 0;
                 }
                 $this->limit = $max;
             }
             $resultsGet = array_slice($resultsGet, $this->offset, $this->limit);
         }
     }
     $collection = array();
     if (count($resultsGet)) {
         $_sum = 0;
         $_avg = 0;
         $_min = 0;
         $_max = 0;
         $first = true;
         foreach ($resultsGet as $key => $id) {
             $object = Data::getById($this->type, $id);
             if (null !== $this->sum) {
                 $getter = getter($this->sum);
                 $_sum += $object->{$getter}();
             }
             if (null !== $this->avg) {
                 $getter = getter($this->avg);
                 $_avg += $object->{$getter}();
             }
             if (null !== $this->min) {
                 $getter = getter($this->min);
                 if (true === $first) {
                     $_min = $object->{$getter}();
                 } else {
                     $_min = $object->{$getter}() < $_min ? $object->{$getter}() : $_min;
                 }
             }
             if (null !== $this->max) {
                 $getter = getter($this->max);
                 if (true === $first) {
                     $_max = $object->{$getter}();
                 } else {
                     $_max = $object->{$getter}() > $_max ? $object->{$getter}() : $_max;
                 }
             }
             $collection[] = $object;
             $first = false;
         }
     }
     if (null !== $this->min) {
         $collection = $_min;
     }
     if (null !== $this->max) {
         $collection = $_max;
     }
     if (null !== $this->sum) {
         $collection = $_sum;
     }
     if (null !== $this->avg) {
         $collection = $_avg / count($collection);
     }
     $cache = Data::cache($this->type, $queryKey, $collection);
     return $collection;
 }
开发者ID:schpill,项目名称:thin,代码行数:93,代码来源:Querydata.php


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