How do I use chunks for nText fields?
How do I use chunks for nText fields?
am 22.03.2007 16:09:04 von David Balch
Hi,
I've got a PHP 5 based website, talking to a MS SQL server database, using
odbc_exec() and related methods.
Some of the database fields are type nText, and return only part of the field
value plus a pointer to the next part.
My database guy pointed to a Microsoft example of how to deal with in VB using
the "GetChunk" method within a while loop:
http://msdn2.microsoft.com/en-us/library/aa905922(SQL.80).as px
I have two problems with this approach:
1) It seems a rather awkward way to do it
2) I can't find any documentation describing how to do it in PHP
Can anyone tell me what I need in order to get the whole value of the field out?
(I haven't been able to subscribe to php-db, so please CC me.)
Cheers,
Dave.
--
David Balch. | Señor web developer.
T: +44 (0)1865 280979 | Technology-Assisted Lifelong Learning.
F: +44 (0)1865 280982 | University of Oxford.
E: david.balch@conted.ox.ac.uk
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: How do I use chunks for nText fields?
am 22.03.2007 17:39:15 von frank
Keep calling odbc_resilt() untill everything is returned:
$str = "";
while ($tmp = odbc_result($rs, $column)) {
$str .= $tmp;
}
You can also use odbc_longreadlen() to set the number of bytes returned by
each call to odbc_result().
- Frank
> Hi,
>
> I've got a PHP 5 based website, talking to a MS SQL server database,
using
> odbc_exec() and related methods.
>
> Some of the database fields are type nText, and return only part of the
field
> value plus a pointer to the next part.
>
> My database guy pointed to a Microsoft example of how to deal with in VB
using
> the "GetChunk" method within a while loop:
> http://msdn2.microsoft.com/en-us/library/aa905922(SQL.80).as px
>
> I have two problems with this approach:
> 1) It seems a rather awkward way to do it
> 2) I can't find any documentation describing how to do it in PHP
>
> Can anyone tell me what I need in order to get the whole value of the
field out?
>
> (I haven't been able to subscribe to php-db, so please CC me.)
>
> Cheers,
> Dave.
>
> --
> David Balch. | Señor web developer.
> T: +44 (0)1865 280979 | Technology-Assisted Lifelong Learning.
> F: +44 (0)1865 280982 | University of Oxford.
> E: david.balch@conted.ox.ac.uk
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: How do I use chunks for nText fields?
am 23.03.2007 15:34:35 von David Balch
Frank M. Kromann kromann.info> writes:
>
> Keep calling odbc_resilt() untill everything is returned:
>
> $str = "";
> while ($tmp = odbc_result($rs, $column)) {
> $str .= $tmp;
> }
>
> You can also use odbc_longreadlen() to set the number of bytes returned by
> each call to odbc_result().
>
> - Frank
Hi Frank,
I'm not having any luck with this - using odbc_result() (code below)
I get "PHP has encountered an Access Violation".
It seems to me that the database is sending something it shouldn't
(maybe a memory pointer?), and PHP isn't able to do anything with it.
Does that make sense?
Cheers,
Dave.
----8<---
header('Content-Type: text/plain;');
$connection = odbc_connect("DSN=xxx;UID=xxx;PWD=xxx","","");
$courseId = 'O07P101COD';
// Database query
$query = "SELECT Refunds FROM vwCourses WHERE CourseID = '".$courseId."'";
$rs = odbc_exec($connection, $query);
$refunds = odbc_result($rs, "Refunds");
echo $refunds;
?>
----8<---
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php