1
votes

When sending data to Model::find or Model::read, e.g. when I want to load a record like:

$this->MyModel->read(null, $id);

I usually wrap the $id in intval(); to protect from unintended or malicious use.

Is this necessary? Does anyone know what cake does to conditions and fields inside a Model::find() query?

PS: I use cakephp bare, no custom setup done, as far as models go.

2

2 Answers

1
votes

No,it's not necessary.Cakephp's mysql layer for DBO has done that for you.

0
votes

As long as you are not using Model->query(..) the Cake ORM will escape these values prior to writing them to the database.

Checking your data types with intval() or is_numeric() is a good practice for validating user supplied content though.