Thanks ahead of time for any responses. I need to search two tables with a common linking field. The search basis will result from viewer form input. The form input will produce a concatenated search/sql statement. The query result set will then be presented. I’ve done this without the use of a framework with a concatenated sql query statement formed with viewer form input. Any advice will be appreciated
Specifically this is the sql I want to put to yii:
$searchStmt = "SELECT *
FROM owners,records
WHERE " ;
if ($city)
$searchStmt .= "owners.city LIKE '%$city%' AND " ;
if ($state)
$searchStmt .= "owners.state LIKE '%$state%' AND " ;
if ($dt_start)
$searchStmt .= "records.dt_start LIKE '%$dt_start%' AND " ;
if ($dt_end)
$searchStmt .= "records.dt_end LIKE '%$dt_end%' AND " ;
if ($beds)
$searchStmt .= "records.beds LIKE '%$beds%' AND " ;
if ($sbPriceRange)
$searchStmt .= "records.sbPriceRange LIKE '%$sbPriceRange%' AND " ;
$searchStmt .= "owners.email = records.email AND " ;
if ($typ)
$searchStmt .= "records.typ LIKE '%$typ%' AND ";
$stmt= substr($searchStmt, 0, strlen($searchStmt)-4) ;
Thanks for replying. Are you suggesting that I use FindBySql in a search controller with Active Record in a search model that searches the two related tables with the defined sql statement? I’m looking for examples.