How to receive data from a store procedure in CodeIgniter 3

0

Create a store procedure in mysql. Using CodeIgniter 3 already configured to use the mysqli driver, I tried to get the data returned by SP but it did not succeed.

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 on IC 3 as follows:

$ query = $ this-> db-> query ("call SP_DataReport (2016,1,1,1, @ d1"));

When viewing the $ 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 that comes from the mysql database via store procedure?

    
asked by anonymous 12.04.2016 / 04:57

0 answers