У меня есть следующий класс 'Course':
class Course {
// The constructor just sets the database object
public function __construct($mysqli) {
$this->mysqli = $mysqli;
}
public function getCourseInfoByID($id) {
$result = $this->mysqli->query("SELECT * FROM courses WHERE id='$id'");
$course_info = $result->fetch_array();
// If found, return the student object
if($course_info) {
return $course_info;
}
return FALSE;
}
}
Когда я объявляю класс и пытаюсь запустить функцию "getCourseInfoByID", я получаю странные результаты (см. Ниже)
Я получаю это:
Array ( [0] => 2 [id] => 2 [1] => 1 [course_type_id] => 1 [2] => 1 [instructor_id] => 1 [3] => Tooele [dz_name] => Tooele [4] => 4 Airport Road [dz_address] => 4 Airport Road [5] => Tooele [dz_city] => Tooele [6] => Utah [dz_state] => Utah [7] => 84020 [dz_zip] => 84020 [8] => [dz_email] => [9] => 2011-12-30 17:25:12 [created] => 2011-12-30 17:25:12 [10] => 2012-01-02 16:24:08 [start_date] => 2012-01-02 16:24:08 [11] => 2012-01-08 16:24:17 [end_date] => 2012-01-08 16:24:17 [12] => 10 [student_slots] => 10 [13] => Brett will also be assisting in teaching this course as Nathan's assistant. Brett paid Nathan quite well to be his assistant. [notes] => Brett will also be assisting in teaching this course as Nathan's assistant. Brett paid Nathan quite well to be his assistant. [14] => 0 [approved_by] => 0 [15] => 0000-00-00 00:00:00 [approved_on] => 0000-00-00 00:00:00 [16] => 0 [completed] => 0 )
Почему дублируется каждая запись?