本文整理汇总了PHP中DB_DataObject::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP DB_DataObject::fetch方法的具体用法?PHP DB_DataObject::fetch怎么用?PHP DB_DataObject::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_DataObject
的用法示例。
在下文中一共展示了DB_DataObject::fetch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSessionFilterSubTable
/**
* @param DB_DataObject $class
* @param string $label
* @param string $field
* @return array
*/
function getSessionFilterSubTable($class, $label, $field)
{
$class->orderBy('value ASC');
$class->find();
$filter = array();
$filter['label'] = $label;
$filter['field'] = $field;
$filter['values'] = array();
$filter['values']['null'] = 'unset';
while ($class->fetch()) {
$filter['values'][$class->id] = $class->value;
}
natcasesort($filter['values']);
return $filter;
}
示例2: showContent
function showContent()
{
$properties = ['id', 'nickname', 'fullname', 'profileurl', 'homepage', 'bio', 'location', 'lat', 'lon', 'location_id', 'location_ns', 'created', 'modified'];
// $config['staleaccounts']['inactive_period'] is number of months
// of inactivity before an account is considered stale.
// Defaults to 3
$inactive_period = common_config('staleaccounts', 'inactive_period') ?: 3;
// Calculate stale date (today - $inactive_period)
$stale_date = new DateTime();
$stale_date->modify('-' . $inactive_period . ' month');
$stale_date = $stale_date->format('Y-m-d');
$offset = ($this->page - 1) * PROFILES_PER_PAGE;
$limit = PROFILES_PER_PAGE + 1;
$dataObj = new DB_DataObject();
// Custom query because I only want to hit the db once
$dataObj->query('SELECT * FROM
(
SELECT local_profiles.*, MAX(n.created) as latest_activity FROM
(
SELECT p.*
FROM profile p
JOIN user u ON u.id = p.id
) local_profiles
LEFT JOIN notice n ON local_profiles.id = n.profile_id
GROUP BY local_profiles.id
ORDER BY latest_activity
) z
WHERE z.latest_activity < "' . $stale_date . '"
OR z.latest_activity IS NULL
LIMIT ' . $offset . ', ' . $limit . ';');
$cnt = $dataObj->N;
$this->elementStart('ul');
while ($dataObj->fetch()) {
$profile = new Profile();
foreach ($properties as $property) {
$profile->{$property} = $dataObj->{$property};
}
$profile->latest_activity = $dataObj->latest_activity;
$pli = new StaleProfileListItem($profile, $this);
$pli->show();
}
$this->elementEnd('ul');
$this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, $this->page, 'staleaccounts', $this->args);
}
示例3: fetch
/**
* Override the fetch functionality to save related objects
*
* @see DB/DB_DataObject::fetch()
*/
public function fetch()
{
$return = parent::fetch();
if ($return) {
if (isset($this->showInMainDetails) && is_string($this->showInMainDetails) && !empty($this->showInMainDetails)) {
// convert to array retrieving from database
$this->showInMainDetails = unserialize($this->showInMainDetails);
if (!$this->showInMainDetails) {
$this->showInMainDetails = array();
}
} elseif (empty($this->showInMainDetails)) {
// when a value is not set, assume set to show all options, eg null = all
$default = self::$showInMainDetailsOptions;
// remove options below that aren't to be part of the default
unset($default['showISBNs']);
$default = array_keys($default);
$this->showInMainDetails = $default;
}
}
return $return;
}
示例4: fetch
function fetch()
{
$this->trigger('prefetch');
if (parent::fetch()) {
$this->_memoized = array();
$this->trigger('postfetch');
return true;
}
return false;
}
示例5: fetch
public function fetch()
{
// avoid those annoying PEAR::DB strict standards warnings it causes
$old = error_reporting();
error_reporting(error_reporting() & ~E_STRICT);
$res = parent::fetch();
// reset
error_reporting($old);
return $res;
}