Getting error while trying to query bucket

Hi there.
I’m trying to run a query that looks like this:

<?php
        function get_all_location_status()
        {
                $myCluster = new CouchbaseCluster();
                $bucket = $myCluster->openBucket();
                $bucket->enableN1ql(array('http://localhost:8093/'));
                $query = CouchbaseN1qlQuery::fromString('SELECT DISTINCT type FROM phonesys-reporting');
                $res = $bucket->query($query);
                var_dump($res);

        }

But the error I’m getting back is:

Fatal error: Uncaught exception ‘CouchbaseException’ with message ‘syntax error - at -’ in [CouchbaseNative]/CouchbaseBucket.class.php on line 312

I’ve tried to run the same command from cbq and it works;

cbq> SELECT DISTINCT type FROM `phonesys-reporting`;
{
    "requestID": "a1879b49-03bd-43f2-824e-2c6f2b888953",
    "signature": {
        "type": "json"
    },
    "results": [
        {
            "type": "audit"
        },
        {
            "type": "server_status"
        },
        {
            "type": "location_status"
        }
    ],
    "status": "success",
    "metrics": {
        "elapsedTime": "17.656371ms",
        "executionTime": "17.583243ms",
        "resultCount": 3,
        "resultSize": 135
    }
}

cbq> 

I have a syntax error somewhere but I can 't see it.

Your bucket name has a special character in N1QL, the dash (-). Enclose the bucket name in backticks instead:

SELECT DISTINCT type FROM `phonesys-reporting`

You seem to have forgotten them in your script