catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

[QUESTION] Convert query to Medoo and "while" #193

Closed Tehiro closed 3 years ago

Tehiro commented 9 years ago

Hi! i have problem. I'm trying to convert: $sql = "SELECT categories.cat_id, categories.cat_name, categories.cat_description, categories.forum_id, COUNT(topics.topic_id) AS topics FROM categories LEFT JOIN topics ON topics.topic_id = categories.cat_id WHERE categories.forum_id = '$id' GROUP BY categories.cat_name, categories.cat_description, categories.cat_id "; to use in Medoo. I wrote this: $id = $forname['id']; $sql = $database->select("categories", [ "[>]topics" => ["topics.topic_id" => "categories.cat_id"], ], [ "categories.cat_id", "categories.cat_name", "categories.cat_description", "categories.forum_id" ], [ "categories.forum_id" => $id ]);

But I get an empty result. Normally I used "while". Now with Medoo I used foreach, I do not know how to use "while".

catfan commented 3 years ago

Use it with raw object. https://medoo.in/api/raw