1

私は12の結果がと呼ばれる列を持つデータベースにあると言いました

thread

message

time_posted

12の結果があり、それらはすべて同じthread魔女が1002です。

私はすべての結果が後に来るようにしようとしていますtime_posted "2013-03-19 17:36:08"。どちらの側にも少なくとも4つのエントリがあるので、この時間の後に4つのエントリを取得する必要があります。

これまでに試したすべての中で、空の配列を受け取ったか2013-03-19 17:36:08、タイムスタンプとして持っている行以外のすべてを取得しました。

これが私が試したことです:

    public function get_messages($thread){

        $time = '2013-03-19 17:36:08';

        $statement = $this->database->prepare("SELECT * FROM chat WHERE thread = ? AND time_posted > '$time'");

        $statement->bindParam(1, $thread);

        $statement->execute();

        $this->result = $statement->fetchAll(PDO::FETCH_ASSOC);

        return $this->result;

    }

<AND>の両方で試しました

助けてくれてありがとう。

ではごきげんよう。

コナー

4

1 に答える 1

1

これを試して:

    $time = '2013-03-19 17:36:08';

    $statement = $this->database->prepare("SELECT * FROM chat WHERE thread = ? AND time_posted >= STR_TO_DATE(?, '%Y-%m-%d %H:%i:%s')");

    $statement->bindParam(1, $thread);
    $statement->bindParam(2, $time );

    $statement->execute();
于 2013-02-19T21:21:59.020 に答える