dpzbzp8728 2016-04-12 09:35
浏览 36

从CodeIgniter 3中的存储过程数据接收

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
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度