0

I have this table: enter image description here

Given a patient name, I want to fetch a row with the highest id, which is:

Agus Maryono - 10 - F - 11 - 2023-01-13 17:08:07

The SQL query to do that is:

SELECT nama_pasien, uid_pasien, kode, id, estimasi_dilayani FROM poli_fisioterapi WHERE nama_pasien="Agus Maryono" ORDER BY id DESC LIMIT 1;

Now I'm trying to do that with Medoo, ideally without manually writing SQL query manually. I used this:

$data_poli_fisioterapi = $database->select("poli_fisioterapi", ["nama_pasien", "uid_pasien", "kode", "id", "estimasi_dilayani"], ["nama_pasien" => "Agus Maryono"], ["ORDER" => ["id" => "DESC"], ["LIMIT" => 1]]);

Instead, it returns all rows which "nama_pasien" = "Agus Maryono":

[
{
nama_pasien: "Agus Maryono",
uid_pasien: 10,
kode: "F",
id: 9,
estimasi_dilayani: "2023-01-13 17:02:03"
},
{
nama_pasien: "Agus Maryono",
uid_pasien: 10,
kode: "F",
id: 10,
estimasi_dilayani: "2023-01-13 17:09:05"
},
{
nama_pasien: "Agus Maryono",
uid_pasien: 10,
kode: "F",
id: 11,
estimasi_dilayani: "2023-01-13 17:08:07"
}
]

What's wrong here?

anta40
  • 6,511
  • 7
  • 46
  • 73

0 Answers0