I would recommend the following:

```php
if (strpos($table, ".") !== false) {
    list($schema, $table) = explode(".", $table);
    $schema = "'" . $schema . "'";
} else {
    $schema = "SCHEMA_NAME()";
}
```

This is simplified by using `list` instead of two assignments, uses `$schema` instead of `$namespace` (which is clearer in this context IMO) and uses the default schema name of the connected user instead of `dbo` which is safer in case the connect user has a different default schema than `dbo`.