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;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP