Re: MSSQL "FOR XML AUTO" php

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

 



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