catfan / Medoo

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

CockroachDB: Relation does not exist #845

Closed tobiasmuehl closed 5 years ago

tobiasmuehl commented 5 years ago

Describe the bug Generated SELECT and INSERT queries always fail with relation "<table name>" does not exist.

Information

Detail Code

// proof that the connection works
print_r($db->query('SELECT 1;')->fetchAll());

// Array
// (
//     [0] => Array
//        (
//            [?column?] => 1
//            [0] => 1
//        )
//
// )

$result = $db->query('suggestions', 'suggestion', ['keyword' => 'test']);
print_r($result);
// Array
// (
// )

print_r($db->error());
// (
//     [0] => 00000
//     [1] => 7
//     [2] => ERROR:  relation "suggestions" does not exist
// LINE 1: SELECT "suggestion" FROM "suggestions" WHERE "keyword" = $1
//                                  ^
// )

Expected output

$result = $db->query('suggestions', 'suggestion', ['keyword' => 'test']);
print_r($result);
// Array
// (
//  [0] => 'foo',
//  [1] => 'bar'
// )

Outruled DB problems, same query with the simplon library returns rows.

catfan commented 5 years ago

You should know what query() parameter is. https://medoo.in/api/query

In your case, you may use select() not query().

https://medoo.in/api/select

tobiasmuehl commented 5 years ago

Pretty sure that's just a typo and I used select, but don't have access to CockroachDB anymore so not an issue for me personally

catfan commented 5 years ago

What's your connection option?

tobiasmuehl commented 5 years ago

pgsql. But I'm fine to leave this issue closed because the database server is already gone regardless.

catfan commented 5 years ago

@tobiasmuehl I'm not sure how CockroachDB works as PostgreSQL. But it may work with if CockroachDB can execute PostgreSQL's queries.