本文整理汇总了PHP中DataSource::read方法的典型用法代码示例。如果您正苦于以下问题:PHP DataSource::read方法的具体用法?PHP DataSource::read怎么用?PHP DataSource::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSource
的用法示例。
在下文中一共展示了DataSource::read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read
public function read(Model $model, $queryData = array(), $recursive = null)
{
parent::read($model, $queryData, $recursive);
$services = array();
if (!empty($queryData['conditions']['servicos'])) {
if (is_array($queryData['conditions']['servicos'])) {
foreach ($queryData['conditions']['servicos'] as $servico) {
$services[] = $this->services[$servico];
}
} else {
$services = $this->services[$queryData['conditions']['servicos']];
}
} else {
// SET DEFAULT FORMAT
$this->format = ECTFormatos::FORMATO_CAIXA_PACOTE;
}
if (!empty($queryData['conditions']['formato'])) {
$this->format = $queryData['conditions']['formato'];
}
// GET VALUES
$return = $this->_getECTValues($queryData['conditions']['altura'], $queryData['conditions']['comprimento'], $queryData['conditions']['largura'], $queryData['conditions']['peso'], $queryData['conditions']['ceporigem'], $queryData['conditions']['cep'], $services, $this->format);
// CONVERTS ARRAY ITERATOR TO ARRAY
$return = iterator_to_array($return, true);
// CONVERT ARRAY OBJECTS TO ARRAY
$return = $this->_toArray($return);
// INSERT MODEL NAME AND RETURNS
return $this->_fixReturn($return);
}
示例2: read
/**
* Reads from cache if it exists. If not, it falls back to the original
* datasource to retrieve the data and cache it for later
*
* @param Model $Model
* @param array $queryData
* @param integer $recursive
* @return array Results
* @see DataSource::read()
*/
public function read(Model $Model, $queryData = array(), $recursive = null)
{
$this->_resetSource($Model);
$key = $this->_key($Model, $queryData);
$results = Cache::read($key, $this->config['config']);
if ($results === false) {
$results = $this->source->read($Model, $queryData, $recursive);
// compress before storing
if (isset($this->config['gzip'])) {
Cache::write($key, gzcompress(serialize($results)), $this->config['config']);
} else {
Cache::write($key, $results, $this->config['config']);
}
$this->_map($Model, $key);
} else {
// uncompress data from cache
if (isset($this->config['gzip'])) {
$results = unserialize(gzuncompress($results));
}
}
return $results;
}
示例3: read
/**
* Reads from cache if it exists. If not, it falls back to the original
* datasource to retrieve the data and cache it for later
*
* @param Model $model
* @param array $query
* @param int $recursive
* @return array Results
* @see DataSource::read()
*/
public function read(Model $model, $query = array(), $recursive = null)
{
// Resets the model's datasource to the original
$model->setDataSource(ConnectionManager::getSourceName($this->source));
$key = $this->_key($model, $query);
$results = Cache::read($key, $this->config['config']);
if ($results === false) {
$results = $this->source->read($model, $query, $recursive);
// compress before storing
if ($this->_useGzip()) {
Cache::write($key, gzcompress(serialize($results)), $this->config['config']);
} else {
Cache::write($key, $results, $this->config['config']);
}
$this->_map($model, $key);
} else {
// uncompress data from cache
if ($this->_useGzip()) {
$results = unserialize(gzuncompress($results));
}
}
Cache::set(null, $this->config['config']);
return $results;
}