Hello all,

 i am implementing multiple search box with all parameter optional

I am doing with postConditions

here is my controller code

$conditions = $this->postConditions($this->data,
                        array(
                                'job_title'                     => 'LIKE',
                                'job_description'               => 'LIKE',
                                'industry'                      => 'LIKE',
                                'job_type'                      => 'LIKE',
                                'location'                      => 'LIKE'
                                )
                        );


This is the sql it produces


SELECT  `Vacancy`.`id`,
                `Vacancy`.`job_title`,
                `Vacancy`.`job_type`,
                `Vacancy`.`industry`,
                `Vacancy`.`location`,
                `Vacancy`.`salary`,
                `Vacancy`.`job_description`,
                `Vacancy`.`active`

                FROM `vacancies` AS `Vacancy`

                WHERE

                `Vacancy`.`job_title` LIKE '%SearchKeyWords%'  AND
                `Vacancy`.`industry` LIKE '%Information Technology%' AND
                `Vacancy`.`job_type` LIKE '%Permanent%' AND `Vacancy`.`location`
LIKE 'London%'


Here when the search string is entered
the search string for example 'linux admin' should be checked with
table field called 'job_title' OR 'job_description'

Again the search string should be '%job_description%' (on both side
%searchString%,i.e,use of "%" on both side)
and for ALL others say job title it should be like 'job_title%' (on
one side searchString%,i.e,use of "%" on one side )

So the Final query should look like

SELECT  `Vacancy`.`id`,
                `Vacancy`.`job_title`,
                `Vacancy`.`job_type`,
                `Vacancy`.`industry`,
                `Vacancy`.`location`,
                `Vacancy`.`salary`,
                `Vacancy`.`job_description`,
                `Vacancy`.`active`

                FROM `vacancies` AS `Vacancy`

                WHERE

`Vacancy`.`job_title`       LIKE   'SearchKeyWords%' OR             //
One side has '%'
`Vacancy`.`job_description` LIKE   '%SearchKeyWords%'            //
(ONLY THIS)two side has '%' AND
`Vacancy`.`industry`        LIKE   'Information Technology%' AND   //
One side has '%'
`Vacancy`.`job_type`        LIKE   'Permanent%'
AND                    //One side has '%'
`Vacancy`.`location`        LIKE   'London
%'                                  //One side has '%'

I have tried all the ways to insert this line

`Vacancy`.`job_title` LIKE 'SearchKeyWords%' OR
`Vacancy`.`job_description` LIKE '%SearchKeyWords%'

but only the `Vacancy`.`job_title` comes up in query and not an OR
between job title and job description.

Please advice

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to