得到存储过程的多组结果,数据库操作要使用mysqli扩展。
例:
<?php
$cn = mysqli_connect("localhost","root","");
mysqli_select_db($cn,'mysql');
$res = mysqli_query($cn,"call proc1()");
while($row = mysqli_fetch_array($res))
{
print_r($row);
}
?>

解决方案 »

  1.   

    PDO要调用 nextRowset方法,指向下一行结果。$sql = 'call proc1()';
    $res = $cn->query($sql);
    do {
       $row = $res->fetchAll(PDO::FETCH_NUM);
       if ($row) 
       {
           print_r($row);
       }
    } while ($res->nextRowset());
      

  2.   

    call sp_web_login(?,?,@error_code);select @error_code;
    这个怎么实现?我每次都取不到@error_code的值.
      

  3.   

    johnpanq(飞花逐月) ( ) 信誉:100  2006-7-11 9:34:53  得分: 0  
    -------------------------------------------
    得到存储过程的多组结果,数据库操作要使用mysqli扩展。
    例:
    <?php
    $cn = mysqli_connect("localhost","root","");
    mysqli_select_db($cn,'mysql');
    $res = mysqli_query($cn,"call proc1()");
    while($row = mysqli_fetch_array($res))
    {
    print_r($row);
    }
    ?>
    没能取到.我的结果是下面这样的.
    ------------------------------------------------------------------------------------
    call sp_get_encrypt_key('test','test1');
    +----------------------------------+----------------------------------+
    | public_key                       | private_key                      |
    +----------------------------------+----------------------------------+
    | 0042f191f042388271aee57dc54d530f | 0042f191f042388271aee57dc54d530f |
    +----------------------------------+----------------------------------+
    1 row in set (0.00 sec)+------------+
    | public_key |
    +------------+
    | NULL       |
    +------------+
    1 row in set (0.00 sec)Query OK, 0 rows affected (0.00 sec)
      

  4.   

    call sp_get_encrypt_key('test','test1');
    -----------------------------there is no error,the sp returns just one result.
      

  5.   

    得到存储过程的多组结果,数据库操作要使用mysqli扩展。
    <?php
    $cn = mysqli_connect("localhost","root","");
    mysqli_select_db($cn,'mysql');
    $res = mysqli_query($cn,"call proc1()");
    while($row = mysqli_fetch_array($res))
    {
        print_r($row);
    }
    ?>这个方法是可行的。
      

  6.   

    yzxlyd(刘懿东大猪头) ( ) 信誉:99  2006-7-19 20:06:07  得分: 0  
    -------------------------------------
    得到存储过程的多组结果,数据库操作要使用mysqli扩展。
    <?php
    $cn = mysqli_connect("localhost","root","");
    mysqli_select_db($cn,'mysql');
    $res = mysqli_query($cn,"call proc1()");
    while($row = mysqli_fetch_array($res))
    {
        print_r($row);
    }
    ?>这个方法是可行的。
    ---------------------------这样只能得到一组结果集的多组数据.
    我说的是有过个result.也就是多个结果集的.这样不行.只能返回第一个结果集.
      

  7.   

    多个结果集。
    mysqli_multi_query();
    参考:http://cn2.php.net/manual/en/function.mysqli-multi-query.php