On Jun 7, 5:11 pm, francky06l <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I am starting to use cake 1.2 for a project. I want to do things in
> the "cake" way and on the simple tests db I wanted to retrieve the
> street name by soundex as well as checking the soundex of the reverse
> string.
>
> My query look like this :
>
> // this is needed to reverse the utf-8 string (I am dealing with
> greek right now)
>
> $z = $this->data['Work']['street'];
> preg_match_all('/./us', $z, $ar);
> $x = join('',array_reverse($ar[0]));
>
> $this->data = $this->Test->findAll(array('SOUNDEX( Test.street )'
> => "-!SOUNDEX('{$this->data['Work']['street']}')",
>
> 'SOUNDEX( REVERSE( Test.street) )' => "-!SOUNDEX('{$x}')"));
>
> It seems there is a problem into the formatting of the query, because
> of the 2 functions "SOUNDEX( REVERSE( ". The formatted query gives
> this :
>
> Query: SELECT `Test`.`id`, `Test`.`street`, `Test`.`rstreet` FROM
> `tests` AS `Test` WHERE SOUNDEX(` Test`.`street `) =
> SOUNDEX('ΓΕΩΡΓΙΟΥ') AND SOUNDEX( REVERSE(` Test`.`street) `) =
> SOUNDEX('ΥΟΙΓΡΩΕΓ')
>
> There is a slight problem around the content of REVERSE, a quote is
> dropped after the parentheses and missing before.
> I solved my problem by wiriting the query string itself, but this
> problem occurs every time you combine SQL functions.
Put backticks around the `Model`.`field` in your constraint array key
and cake won't interfere.
i.e. something like
'SOUNDEX( REVERSE( `Test`.`street`) )' => "-!SOUNDEX('{$x}')"));
hth,
AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---