PHP ile PostgreSQL yeni 3 soruları seçmek için

2 Cevap php

How can you select the titles of the newest 3 questions from PostgreSQL database by PHP?

My attempt in PHP

$result = pg_prepare($dbconn, "query1", "SELECT title FROM 
    questions ORDER BY was_sent_at_time 
    WHERE question_id = $1;");
$result = pg_execute($dbconn, "query1", array(7, 1, 9);     
   // Problem HERE, since I do not know how you can get the 3 newest questions

2 Cevap

MySQL gibi bir şey olmazdı

SELECT title FROM questions ORDER BY was_sent_at_time DESC LIMIT 3;

Hala Postgres değişiklik olmaksızın geçerlidir emin değilim.

Sorgunuzla değiştirin:

"SELECT title FROM questions WHERE question_id = $1 
ORDER BY was_sent_at_time DESC LIMIT 3;"