Re: MSSQL "FOR XML AUTO" php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Robert
but one thing i can't understand.
As you can see in my first message
freetds log contains such thing:
----------------------------------------------------------------------------------------------
19:32:55.245996 tds_put_string converting 23 bytes of "exec GET_RESUME_AS_XML1"
19:32:55.246050 tds_put_string wrote 46 bytes
Sending packet @ 19:32:55.246091
0000 01 01 00 36 00 00 01 00-65 00 78 00 65 00 63 00 |...6.... e.x.e.c.|
0010 20 00 47 00 45 00 54 00-5f 00 52 00 45 00 53 00 | .G.E.T. _.R.E.S.|
0020 55 00 4d 00 45 00 5f 00-41 00 53 00 5f 00 58 00 |U.M.E._. A.S._.X.|
0030 4d 00 4c 00 31 00 - |M.L.1.|



19:32:55.246297 in dbsqlok() Received header @ 19:32:55.246705 0000 04 01 00 c2 00 34 01 00- |.....4..|


Received packet @ 19:32:55.246790 0000 81 01 00 00 00 01 00 63-00 10 00 00 01 00 78 00 |.......c ......x.| 0010 28 58 00 4d 00 4c 00 5f-00 46 00 35 00 32 00 45 |(X.M.L._ .F.5.2.E| 0020 00 32 00 42 00 36 00 31-00 2d 00 31 00 38 00 41 |.2.B.6.1 .-.1.8.A| 0030 00 31 00 2d 00 31 00 31-00 64 00 31 00 2d 00 42 |.1.-.1.1 .d.1.-.B| 0040 00 31 00 30 00 35 00 2d-00 30 00 30 00 38 00 30 |.1.0.5.- .0.0.8.0| 0050 00 35 00 46 00 34 00 39-00 39 00 31 00 36 00 42 |.5.F.4.9 .9.1.6.B| 0060 00 d1 10 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........| 0070 00 00 00 00 00 00 00 00-00 00 00 24 00 00 00 3c |........ ...$...<| 0080 00 72 00 6f 00 77 00 20-00 63 00 6f 00 6c 00 31 |.r.o.w. .c.o.l.1| 0090 00 3d 00 22 00 64 00 61-00 74 00 61 00 22 00 2f |.=.".d.a .t.a."./| 00a0 00 3e 00 ff 11 00 c1 00-01 00 00 00 79 00 00 00 |.>...... ....y...| 00b0 00 fe 00 00 e0 00 01 00-00 00 |........ ..| ----------------------------------------------------------------------------------------

If this information is ( if i can say it like this) already come to my machine
and i can read it in freetds.log i don't think it's encoding problem.



*

*



Robert Twitty wrote:

HI Bozhan

When you append the "FOR XML" clause at the end of a query, the xml data
will be sent in a single column result set. The column's type is ntext,
which is not easily handled by FreeTDS and PHP. The reason is because it
is UC2-2 encoded UNICODE text. UNICODE text is easier to deal with if it
is encoded using UTF-8. Somewhere in FreeTDS's docs it talks about how to
do this.

However, rather than using FreeTDS, I would suggest using ODBTP, which is
available at http://odbtp.sourceforge.net. One of its biggest strengths
and advantages over FreeTDS is UNICODE data and query processing. It had
no problems executing your "FOR XML" query.  It also provides support for
all of PHP's mssql functions, so you don't have to change your code.

-- bob

On Tue, 14 Sep 2004, Bozhan Boiadzhiev wrote:



Hello i have such problem
Executing this script
php code:
<?php
session_start();
include "../msdb_conn.php";


$stmt_page=mssql_init("GET_RESUME_AS_XML"); mssql_bind($stmt_page,"RETVAL",$returnval,SQLVARCHAR);

  $execute_stmt=mssql_execute($stmt_page);



echo mssql_num_rows($execute_stmt);
do {
     while ($row = mssql_fetch_array($execute_stmt)) {
         print_r($row);
     }
 } while (mssql_next_result($execute_stmt));
?>



-- SNIP --


but the only result is:
1Array ( [0] => [XML_F52E2B61-18A1-11d1-B105-00805F49916B] => )



a little simple example:

PROCEDURE:

CREATE   PROCEDURE PRINT_XML_DATA
AS
SELECT 'data' as col1
FOR XML RAW
GO

executing this procdure form SQL Query Analyzer gives:
XML_xxxxxxxx-xxxx-xxxx--xxxx(whaever)
<row col1="data"/>

<?php

include "../msdb_conn.php";

/*
   $stmt_page=mssql_init(" PRINT_XML_DATA");
   $execute_stmt=mssql_execute($stmt_page);
*/
// I can execute this way too but whit same result !!!!


$query=mssql_query("exec PRINT_XML_DATA"); echo mssql_num_rows($query);


/* while ($row = mssql_fetch_array($query)) { print_r($row); } */ // I can execute this way too but whit same result !!!!

do {
      while ($row = mssql_fetch_array($query)) {
          print_r($row);
      }

  } while (mssql_next_result($query));
?>

and result is:
Array ( [0] => [XML_F52E2B61-18A1-11d1-B105-00805F49916B] => )



-- SNIP --


Can some one to tell me or to suggest me how i can do this thing.
And where is the problem in PHP or in FreeTDS or in me:) ???

Thanks
Bozhan




-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux