catfan / Medoo

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

MySql views not working #896

Closed davehibshman closed 4 years ago

davehibshman commented 4 years ago

Describe the bug I can't find any documentation about querying MySQL views using this library. Tying to pass the view to select("viewname", "") or using query("select from viewname")->fetchAll() don't seem to work. Should they? Can they?

Information

Detail Code

/* returns false */
$app->get("/users", function (Request $request, Response $response, array $args) {
    return $response->write(json_encode($this->database->select("users", "*")));
});

/* returns [] */
$app->get("/users", function (Request $request, Response $response, array $args) {
    return $response->write(json_encode($this->database->query("select * from users")->fetchAll()));
});

Expected output Since the user I am logged in as has access to these view object in the database I would expect to be able to query them and get the array of data returned.

davehibshman commented 4 years ago

Switched to raw PDO to verify it was working and it works.

For other reasons I ended up resetting the login on the mysql login to % wildcard instead of localhost. When returning to Medoo, while still specifying localhost in the Medoo constructor, I am now able to select from the view. I can't imagine this fixed it but closing the issue none-the-less as it's working now.