Create a stored procedure in mysql. Using CodeIgniter 3 already configured to use the mysqli driver, I tried to receive the data returned by the SP but did not get success. SP:
CREATE DEFINER=`root`@`localhost` PROCEDURE `SP_DadosRelatorio`(IN ano INT, IN mes INT, IN retirada INT, IN produto INT,
OUT d1 INT)
BEGIN
SELECT
ifnull(sum(qtde),0) INTO d1
FROM
saida_produto
WHERE EXTRACT(YEAR FROM data_saida) = ano
and
EXTRACT(MONTH FROM data_saida) = mes
and
EXTRACT(DAY FROM data_saida) = 1
and tipo_retirada = retirada
and id_produto = produto;
I made the call in CI 3: $query = $this->db->query("call SP_DadosRelatorio(2016,1,1,1,@d1"));
call the function $query->result(); I got the following message:
> > object(CI_DB_mysqli_result)[51] public 'conn_id' =>
> object(mysqli)[18]
> public 'affected_rows' => null
> public 'client_info' => null
> public 'client_version' => null
> public 'connect_errno' => null
> public 'connect_error' => null
> public 'errno' => null
> public 'error' => null
> public 'error_list' => null
> public 'field_count' => null
> public 'host_info' => null
> public 'info' => null
> public 'insert_id' => null
> public 'server_info' => null
> public 'server_version' => null
> public 'stat' => null
> public 'sqlstate' => null
> public 'protocol_version' => null
> public 'thread_id' => null
> public 'warning_count' => null public 'result_id' => boolean true public 'result_array' =>
> array (size=0)
> empty public 'result_object' =>
> array (size=0)
> empty public 'custom_result_object' =>
> array (size=0)
> empty public 'current_row' => int 0 public 'num_rows' => null public 'row_data' => null
How do I access the value of @ d1 coming from mysql database via stored procedure in IC3?
when i try execute $query->result(); The PHP show me:
A PHP Error was encountered
Severity: Error
Message: Call to a member function fetch_object() on boolean
Filename: mysqli/mysqli_result.php