0

I have a really complex query: so much table (and... so much nested model). I feel more comfortable, using raw SQL query rather than CakePHP query syntax. As far as I know, I should prefear CakePHP syntax, cause it is almost immune to attack.

Considering that I won't use Cake's syntax, there's a way to join the security of cake approach with the practicalness of raw SQL approach?

1
  • You can try use PDO with Prepare statements without bothering what user enters letter, number or illegal character. Still I would prefer stick with cake as much it possible due models management reasons. Commented Sep 1, 2012 at 5:55

1 Answer 1

1

I think if you use pdo adapter for mysql, its provide security for sql injection.

I addition you can use Sanitize::clean and Sanitize::escape to escape your query.

Sign up to request clarification or add additional context in comments.

2 Comments

I had even thinked to validate input arguments and if needed raise error to avoid real query. For example: if the where needs a int, then, if i get a string raise error.
if you do it, you can be sure that you protect your query from sql injection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.