Instead of:

```php
->condition('cid', db_like($cid) . '%', 'LIKE')
```
We need:
```php
->condition('cid', '%' . db_like($cid) . '%', 'LIKE')
```