Re: How to do this SQL query in Cake way - use one column twice in the same query.

2008-12-22 Thread Webweave

>From your original SQL, it looks like you want to AND two LIKE
statements (which is guaranteed to be very slow), but that said, why
not just do that in your conditions:

$whereArray = array('conditions' => array(
'AND' => array(
'referer like %google%',
'referer like %\%E6\%B5\%81\%E7\%A8\%8B
\%E5\%9B\%BE%',
'request_path like /blog/posts/view/
flowchart-howtos%'
)
)

On Dec 22, 12:01 am, "felixd...@gmail.com" 
wrote:
> Hi all, I have such a SQL statement to query:
> SELECT * FROM `mytable` WHERE `referer` LIKE '%google%' AND `referer`
> LIKE '%\%E6\%B5\%81\%E7\%A8\%8B\%E5\%9B\%BE%' AND `request_path` LIKE
> '/blog/posts/view/flowchart-howtos%'
>
> I use the column `referer` twice in the same SQL query.
>
> I tried with
>
> $this->LogParser->find(array('referer LIKE'=>array('%google%', '%\%E6\
> %B5\%81\%E7\%A8\%8B\%E5\%9B\%BE%'), 'request_path LIKE'=>'/blog/posts/
> view/flowchart-howtos%'));
>
> which gave me
>
> ... WHERE `referer LIKE` IN ('%google%', '%E6%B5%81%E7%A8%8B%E5%9B
> %BE') ...
>
> apparently that is not correct.
>
> Any can kindly help me? Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



How to do this SQL query in Cake way - use one column twice in the same query.

2008-12-22 Thread felixd...@gmail.com

Hi all, I have such a SQL statement to query:
SELECT * FROM `mytable` WHERE `referer` LIKE '%google%' AND `referer`
LIKE '%\%E6\%B5\%81\%E7\%A8\%8B\%E5\%9B\%BE%' AND `request_path` LIKE
'/blog/posts/view/flowchart-howtos%'

I use the column `referer` twice in the same SQL query.

I tried with

$this->LogParser->find(array('referer LIKE'=>array('%google%', '%\%E6\
%B5\%81\%E7\%A8\%8B\%E5\%9B\%BE%'), 'request_path LIKE'=>'/blog/posts/
view/flowchart-howtos%'));

which gave me

... WHERE `referer LIKE` IN ('%google%', '%E6%B5%81%E7%A8%8B%E5%9B
%BE') ...

apparently that is not correct.

Any can kindly help me? Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---