dqst96444 2013-09-27 07:05
浏览 30
已采纳

检索包含xml的数据库列

I must admit it is late and I am tired. Perhaps too tired to see what is in front of me! I have a MS database table where 1 column contains xml data. I need to retrieve the data into a variable (or whatever) and then display it.

I am connected to the database. I can retrieve data from any other column. However, when I execute this statement on column 1(which contains the xml):

$Text = sqlsrv_get_field( $results, 1); 

I get this error: SearchPatentID(): 22872056 is not a valid stream resource...

I do NOT get this error on any other column in the table. So,

$Whatever = sqlsrv_get_field( $results, 3); 

works just fine. I am not concerned about how to display the data, just how to get it so I can do what I need.

thanks in advance it is ALWAYS greatly appreciated. Shimon

  • 写回答

1条回答 默认 最新

  • dpd3982 2013-09-27 20:15
    关注

    I finally found the answer to my problem.

    $stream = sqlsrv_get_field( $results, 1, SQLSRV_PHPTYPE_STREAM( SQLSRV_ENC_CHAR));
    

    Then you can loop through $stream to display or do whatever you want with the data.

    while( !feof( $stream))
    { 
        $str = fread( $stream, 10000);
        echo $str;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答