コード例 #1
0
 public function get_names()
 {
     $temp_subject = new Subject();
     $temp_subject->load($this->subject_id_1);
     $this->subject_1_name = $temp_subject->print_name();
     $temp_subject->load($this->subject_id_2);
     $this->subject_2_name = $temp_subject->print_name();
 }
コード例 #2
0
 $query = $db->prepare("SELECT id, subject_name, date_updated FROM subjects WHERE subject_name LIKE ? ORDER BY subject_name");
 $data = array('%' . $q . '%');
 if ($query->execute($data)) {
     while ($row = $query->fetch()) {
         $output .= '<p><a href="index.php?p=subject_view&id=' . $row['id'] . '">' . $row['subject_name'] . '</a><br /><span class="small">Updated: ' . $row['date_updated'] . '</span></p>';
     }
 }
 // Next, see if the query appears in any aspects, and return the Subject if that's the case.
 $aspect_q = $db->prepare("SELECT * FROM aspects INNER JOIN aspect_types ON aspects.aspect_type=aspect_types.id INNER JOIN subjects_aspects ON aspects.id=subjects_aspects.aspect_id WHERE aspect_data LIKE ?");
 if ($aspect_q->execute($data)) {
     $output .= "<h3>Aspect Results:</h3>";
     while ($row = $aspect_q->fetch()) {
         $ts = new Subject();
         $ts->load($row['subject_id']);
         $output .= '<p>';
         $output .= 'Found in an aspect of ' . $ts->print_name();
         $output .= '</p>';
     }
 }
 // finally, let's query the web.
 $ddg = new DuckAgent();
 $ddg->query($q);
 if (!empty($ddg->result)) {
     $output .= '<h3>From the web:</h3>';
     $websearch = json_decode($ddg->result, true);
     if (isset($websearch['AbstractText'])) {
         $output .= '<p>Abstract: ' . $websearch['AbstractText'] . '<br /> <span class="small">Source: ' . $websearch['AbstractSource'] . '</span></p>';
     }
     if (!empty($websearch['Definition'])) {
         $output .= '<p>Definition: ' . $websearch['Definition'] . '</p>';
     }