extbase(TYPO3)中的setOrderings用于Array的第二级

Mik*_*ike 3 php typo3 extbase

我希望通过此函数在我的TYPO3扩展的EventRepository中按日期排序我的"约会".

    public function findAll() {

    // Sort appointments ascending
    $query = $this->createQuery();
    Return $query->setOrderings (
        Array('appointments' => Tx_Extbase_Persistence_Query::ORDER_ASCENDING)
    )->execute();

}
Run Code Online (Sandbox Code Playgroud)

我需要获得数组的第二级,例如:'appointmentments.start_date'我的数组看起来像这样:

images => 'originalPreviewJW__2_.jpg' (25 chars)
     categories => Tx_Extbase_Persistence_ObjectStorageprototype object (2 items)
     appointments => Tx_Extbase_Persistence_ObjectStorageprototype object (4 items)
        000000006052eef7000000009b41588e => Tx_SzEvents_Domain_Model_Appointmentprototypepersistent entity (uid=3, pid=13)
              titel => 'entertainment area' (18 chars)
              startDate => DateTimeprototype object (2013-08-22T10:00:00+02:00, 1377158400)
              endDate => DateTimeprototype object (2013-08-22T20:00:00+02:00, 1377194400)
Run Code Online (Sandbox Code Playgroud)

Mic*_*ael 5

这应该工作

public function findAll() {
    // Sort appointments ascending
    $query = $this->createQuery();
    return $query->setOrderings (
        Array('appointments.startDate' => Tx_Extbase_Persistence_Query::ORDER_ASCENDING)
    )->execute();
}
Run Code Online (Sandbox Code Playgroud)

  • 大!看到引用的列被称为``appointmentments.startDate``非常重要,尽管表字段名称实际上是``start_date``!同样重要的是:解决排序方向常量的方法已在ExtBase中从``Tx_Extbase_Persistence_Query :: ORDER_ASCENDING``更改为``\ TYPO3\CMS\Extbase\Persistence\QueryInterface :: ORDER_ASCENDING`` (6认同)