We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

DB escaped quote returned as encoded

Hi,

I have a problem where a string is escaped, but then not converted back. Below is a bit more detail:

class Car extends \Phalcon\Mvc\Model {...}

$c = (new Car())->setName("Bob's car")->save();

That is saved in DB (MariaDB) as "Bob's car". All fine so far, however, when we do:

$name = $c->getName();

Rather than getting "Bob's car", I'm still getting "Bob's car".

What am I doing wrong? What do I have to configure to auto decode the string?

Thanks in advance.



85.5k

probably your html , var_dump ( x debug ) is encoging it

it displays fine with

{{ car.name }}

so I doubt it would be that.



6.8k
Accepted
answer

After checking a lot of things that turned out to be unrelated I have found the culprit.

When assigning that particular value, I've used

$this->request->getPost('name', 'string');

Which passes the value through filter var, whilst annoying, it's not exactly Pahlcon's fault.