class Registration_model extends CI_Model {
function __construct() {
parent::__construct();
}
function check_email_availability($email)
{
$sql = "CALL proc_1301('$email');";
$query = $this->db->query($sql) or die(mysql_error());
return $query->row_array();
}
function check_username_availability($username)
{
$sqlt = "CALL proc_1303('$username');";
$query = $this->db->query($sqlt) or die(mysql_error());
return $query->row_array();
}
function process_registration($username, $email, $password)
{
$sql = "CALL `proc_1302`('$username', '$email', '$password');";
$query = $this->db->query($sql) or die(mysql_error());
return $query->result_array();
}
this is my controller code which calls three functions from model one by one:
$emailCheckRes = $this->Registration_model->check_email_availability($email);
$usernameCheckRes = $this->Registration_model->check_username_availability($username);
$this->data['regRes'] = $this->Registration_model->process_registration($username, $email, $password);
my problem is when i run only one function it runs successfully but when i run two of them or all three it shows blank page… any idea why ???
SOLUTION
So finally the only solution we got for my own problem is :
/* ADD THIS FUNCTION IN SYSTEM/DATABASE/DB_ACTIVE_REC */
/* USAGE $this->db->freeDBResource($this->db->conn_id); */
function freeDBResource($dbh){
while(mysqli_next_result($dbh)){
if($l_result = mysqli_store_result($dbh)){
mysqli_free_result($l_result);
}
}
}
The problem is related to CodeIgniter’s active recors and multiple database stored procedure calling.
First of all check that dbdriver parameter (application/config/database.php) is set to mysqli.
Then, as described in “Calling a stored procedure from CodeIgniter’s Active Record class” question on StackOverflow, adding to system/database/DB_active_rec.php the following function:
..And in your controller use:
after any stored procedure calling.