rafaelwendel / phpsupabase

PHP Client to use Supabase
MIT License
187 stars 18 forks source link

Count records on table #16

Closed CatAnonymous closed 1 year ago

CatAnonymous commented 1 year ago

I tried

$query = $service->initializeQueryBuilder();

try{
    $listProducts = $query->select('COUNT(*)')
                ->from('messages')
                ->execute()
                ->getResult();
    var_dump($listProducts);
}
catch(Exception $e){
    echo $e->getMessage();
}

Result

Client error: `GET https://***.supabase.co/rest/v1/messages?select=COUNT(*)` resulted in a `400 Bad Request` response:
{"code":"PGRST200","details":"Searched for a foreign key relationship between 'messages' and 'COUNT' in the schema 'publ (truncated...)