Reputation: 1
My Model error: Call to undefined method CI_DB_mysqli_driver::result()
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class teacher_feedback extends CI_Model {
public function teacher_feedback_query($teacher)
{
$teacher_feedback_query = 'SELECT TD.name, TD.subject, TFA.answer_value, SBI.first_name, TFSAC.comment, TFSC.comment, TFQ.teachers_feedback_question_id FROM teacher_details as TD inner join teachers_feedback_student_answer as TFSA on TFSA.teacher_id = TD.teacher_id inner join teachers_feedback_answer as TFA on TFA.teachers_feedback_answer_id = TFSA.teachers_feedback_answer_id inner join teachers_feedback_student_answer_comment as TFSAC on TFSAC.teacher_id = TD.teacher_id inner join student_basic_info as SBI on SBI.student_id=TFSAC.student_id inner join teachers_feedback_student_comment as TFSC on TFSC.student_id = SBI.student_id inner join teachers_feedback_question as TFQ on TFQ.teachers_feedback_question_id = TFSA.teachers_feedback_question_id where TD.teacher_id = ?';
$teacher_query = $this->db->query($teacher_feedback_query,array($teacher));
$teacher_feedback_result = $this->db->result($teacher_query);
return $teacher_feedback_result();
}
}
?>
Upvotes: 0
Views: 4044
Reputation: 509
Most of the time these type of error comes because of we apply core php code on it and ci have its own way to apply this. So sometimes we succeed to apply some core code but sometimes not. In that case, try to go on ci doc you most probably find your solution. Good luck.
Upvotes: 0
Reputation: 37318
I think what you are trying to do here is wrong. result
method should be called to the query result and not on the db
object.
Try this:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class teacher_feedback extends CI_Model {
public function teacher_feedback_query($teacher)
{
$teacher_feedback_query = 'SELECT TD.name, TD.subject, TFA.answer_value, SBI.first_name, TFSAC.comment, TFSC.comment, TFQ.teachers_feedback_question_id FROM teacher_details as TD inner join teachers_feedback_student_answer as TFSA on TFSA.teacher_id = TD.teacher_id inner join teachers_feedback_answer as TFA on TFA.teachers_feedback_answer_id = TFSA.teachers_feedback_answer_id inner join teachers_feedback_student_answer_comment as TFSAC on TFSAC.teacher_id = TD.teacher_id inner join student_basic_info as SBI on SBI.student_id=TFSAC.student_id inner join teachers_feedback_student_comment as TFSC on TFSC.student_id = SBI.student_id inner join teachers_feedback_question as TFQ on TFQ.teachers_feedback_question_id = TFSA.teachers_feedback_question_id where TD.teacher_id = ?';
$teacher_query = $this->db->query($teacher_feedback_query,array($teacher));
//$teacher_feedback_result = $this->db->result($teacher_query);
$teacher_feedback_result = $teacher_query->result();
return $teacher_feedback_result; // Remove parenthesis, $teacher_feedback_result is not a function
}
}
?>
EDIT:
About the error Call to undefined method CI_DB_mysqli_driver::result()
PHP throws this error because CodeIgniter MySQLi adapter class does not have a method result
. Here is the CodeIgniter MySQLi driver class. You can check it, there is no such method result
:
https://github.com/bcit-ci/CodeIgniter/blob/develop/system/database/drivers/mysqli/mysqli_driver.php
So, when you are calling $this->db->result($teacher_query)
, $this->db
is attached to CI_DB_mysqli_driver
and thus you get an error that you’re calling an undefined method.
Upvotes: 1