function DatabaseHandler::get_course_db_row

7.x DatabaseHandler.php DatabaseHandler::get_course_db_row($course_id)
6.x DatabaseHandler.php DatabaseHandler::get_course_db_row($course_id)

Returns an object from db query for a row we find with matching course_id, from the most recent catalog year.

File

classes/DatabaseHandler.php, line 1103

Class

DatabaseHandler

Code

function get_course_db_row($course_id) {
  $res = db_query("SELECT * FROM courses 
                     WHERE course_id = ? 
                     AND exclude != 1
                     AND delete_flag != 1
                     ORDER BY `catalog_year` DESC", array($course_id));
  $cur = db_fetch_object($res);

  if (!$cur) {
    // Couldn't find it, so lift the exclude requirement.

    $res = db_query("SELECT * FROM courses 
                     WHERE course_id = ?
                     AND delete_flag != 1
                     ORDER BY `catalog_year` DESC", array($course_id));
    $cur = db_fetch_object($res);
  }



  return $cur;
}