我有一个巨大的$events
. 为了输出这个海量的信息,我做:
<?php foreach ($this->events as $usern): ?><?php foreach ($usern as $user): ?>
<tr>
<td><?php echo $user['id']; ?></td>
<td><?php echo $user->resource_types; ?></td>
<td><?php echo $user->resource_ids; ?></td>
<td><?php echo $user->action; ?></td>
<td><?php echo $this->owner($user->originator); ?></td>
<td><?php echo $user->event_date; ?></td>
<td>
<?php //if($this->canManageBusiness($user->id)): ?>
<?php // endif ?>
</td>
</tr>
<?php endforeach ?><?php endforeach ?>
有趣的是我可以同时使用$user->id
和$user['id']
sintax。但是没关系。我怎样才能按$user['id']
desc 对这个海量进行排序?
编辑:我从数据库中获取数据,但不是通常的方式,所以我不能使用 sql 语法对结果进行排序:
$events[] =$this->_dbTable->fetchAll($this->_dbTable->select()->from($this->_dbTable, array('id','resource_types','resource_ids','action','originator','event_date'))->where('resource_types = ?', 'business')->where('resource_ids',$bus->id));
$events[] =$this->_dbTable->fetchAll($this->_dbTable->select()->from($this->_dbTable, array('id','resource_types','resource_ids','action','originator','event_date'))->where('resource_types = ?', 'document-type')->where('resource_ids',$dt->id));
return $events