Sanitize help on Raw sql

I have several complex queries in my plugin that require me to use the methods ->query() , and not ->find() .

I could not figure out how to clear raw sql, so I figured that someone here could help me.

So, the first step is to enable App:import("sanitize"); before class declaration.

Now let's say that I have this:

$query = $this->Mytable->query("SELECT * FROM mytable WHERE " . $WHERECLAUSE . ";");

Can someone help me in disinfecting my request as I am completely lost in the cookbook.

Thanks for your help, this is much appreciated.

+4
source share
2 answers

Use this: Sanitize :: clean ($ query, $ options)

+1
source

Sanitize :: clean is used for values ​​/ integer arrays like $ this-> data.

 $WHERECLAUSE = Sanitize::clean($whereclause, array('escape')); $query = $this->Mytable->query("SELECT * FROM mytable WHERE " . $WHERECLAUSE . ";"); 

It will be a trick.

  array ('escape') 
used for SQL statements.
0
source

Source: https://habr.com/ru/post/1446179/


All Articles