Exemplo n.º 1
0
 private static function getBuilderWithParam($find_name, $find_age)
 {
     $name = false;
     $age = false;
     if ($find_name) {
         $name = true;
     }
     if ($find_age) {
         $age = true;
     }
     $results = array();
     $explanation = "";
     if ($name && !$age) {
         // Only Name Specified
         // First-name and Last-name search
         // $results = DB::table('FoundPeople')
         //                     ->where('first-name', '=', $updates_name)
         //                     ->orWhere('last-name', '=', $updates_name)
         //                     ->get();
         // Substr match
         // $results = FoundPeople::whereRaw('first_name LIKE ? and last_name LIKE ?', array(
         //                                     '%'.$find_first_name.'%', '%'.$find_last_name.'%'
         //                                 ));
         $results = Helper::searchTableForName(FoundPeople::TABLE_NAME, $find_name);
         // TODO : separate out exact matches and substr matches and disp them separately
     } elseif ($age && !$name) {
         // Only Age Specified
         $results = FoundPeople::where('age', '=', $find_age);
     } elseif ($name && $age) {
         // Name, Age Specified
         // $results = FoundPeople::whereRaw('( first_name LIKE ? and last_name LIKE ? ) and age = ?', array(
         //                             '%'.$find_first_name.'%', '%'.$find_last_name.'%', $find_age
         //                         ));
         $results = Helper::searchTableForNameAndAge(FoundPeople::TABLE_NAME, $find_name, $find_age);
         // TODO : separate out exact matches and substr matches and disp them separately
     }
     return $results;
 }