I have what I think to be a normal query-call in CakePHP - it works for all results, but when a field has a special character in it, the field will return empty. It doesn't break - and it still gives me the rest of the fields - it's just that one field that's empty.
Example:
$this->paginate = array(
'conditions' => array(
'Item.name != ' => '',
),
);
$data = $this->paginate('Item');
This will return all the items in my table (including the one that I thought had an empty name field) - but when I try to echo the name to the page, it works for every item except the one with a special character (é). I changed it to a normal "e" and it shows up fine.
How can I return results even if they have a special character in their name? Thanks in advance!
Check to make sure your database uses the right encoding (UTF-8, ideally) and you have configured Cake to use this same encoding as well in config/database.php
:
class DATABASE_CONFIG {
public $default = array(
...
'encoding' => 'utf8'
);
}
If you have some encoding mismatch, your app has probably stored garbage in the database already, so make sure you test with the right data and/or a fresh database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With