来自存储库的Extbase-DISTINCT值

时间:2018-12-25 12:46:36

标签: extbase

从我的数据库中获取唯一的房间号。

我的表是tx_example_domain_model_room,其中包含列startdatetime,enddatetime和roomKey。我想获取大于给定日期时间的roomKey。当我查询时,结果返回所有大于给定日期时间的roomKey,出现所有具有超过给定日期时间的roomKey。但是,它并不明显。我想得到不同的房间。下面是我的代码:

List.html列表

f:form.select options="{roomKeys}" optionLabelField="roomKey"

您能让我知道如何获得独特的价值。还有一个细节:Room是一个模型,包含属性roomKey,startdatetime和enddatatime。

  • 控制器

        $roomKey = $this->roomRepository->RoomKeyFetcher($enddatetime, $startdatetime);
        var_dump($roomKey);
        $unique_rooms = array_unique($roomKey);
    
        $this->view->assign('roomKeys', $unique_rooms);
    

存储库:

public function RoomKey($enddatetime, $startdatetime) {
    $query = $this->createQuery();

    $query->statement('SELECT * FROM tx_example_domain_model_room
                        WHERE startdatetime >= ? OR enddatetime <= ?', 
                        [$enddatetime, $startdatetime]);

    $results = $query->execute();

    return $results;            
}

1 个答案:

答案 0 :(得分:0)

只需在master = input("Enter a word: ") print("\n"* 50 ) word = list(master) length = len(word) right = list("_" * length) tries=7 finished = False while finished == False: guess = input("Guess a letter!") if guess not in master: print("This letter is not in the word.") tries-=1 print(tries," tries left") for letter in word: if letter == guess: index = word.index(guess) right[index] = guess word[index] = "_" print(right) if list(master) == right: print("You win!") again = input("Again? y/n ") if again == "y" or "Y": master = input("Enter a word: ") print("\n" * 50) word = list(master) length = len(word) right = list("_" * length) else: finished = True elif tries == 0: print("Game Over!") finished = True 上使用DISTINCT关键字即可。

roomkey