[freetds] dbresults

Arnar Birgisson ArnarB at oddi.is
Mon May 26 06:26:17 EDT 2003


Any word of this at all?

Here's a test php script..

<?php

$conn = mssql_connect("stmdatabase", "stmkerfi_arnarb", "xxx");
mssql_select_db("starfsmannakerfi");
$sp = mssql_init("sp_get_athugasemdir_starfsmanns");
$kt = '2704814509';
mssql_bind($sp, "@kennitala", $kt, SQLCHAR, false, false, 10);
$res = mssql_execute($sp);
print("res #1\n");
while ($data = mssql_fetch_assoc($res)) {
   print_r($data);
}
$i=1;
while (mssql_next_result($res)) {
   print("res #".++$i."\n");
   while ($data = mssql_fetch_assoc($res)) {
      print_r($data);
   }
}

?>

Running this on linux (with freetds) yields..

res #1
Array
(
    [mat] => 1
    [dags_planad] => 2003-05-11 00:00:00
    [dags_tekid] => 
    [fj_athugasemda] => 2
    [fj_opinna] => 2
)
res #2
Array
(
    [stada] => 1
    [fjoldi] => 1
)
Array
(
    [stada] => 2
    [fjoldi] => 2
)
res #3
Array
(
    [athugasemd] => 4
    [eigandi] => arnarb2
    [titill] => Prufuathugasemd hjá arnarb2
    [dags_skrad] => 2003-05-21 14:09:54
    [sidast_breytt] => 2003-05-21 14:10:25
    [dags_deadline] => 
    [birt_vegna] => 1
)

but the same script run on windows, with the same version of php linked against microsoft's dblib, correctly yields

res #1
res #2
Array
(
    [mat] => 1
    [dags_planad] => May 11 2003 12:00AM
    [dags_tekid] =>
    [fj_athugasemda] => 2
    [fj_opinna] => 2
)
res #3
Array
(
    [stada] => 1
    [fjoldi] => 1
)
Array
(
    [stada] => 2
    [fjoldi] => 2
)
res #4
Array
(
    [athugasemd] => 4
    [eigandi] => arnarb2
    [titill] => Prufuathugasemd hjá arnarb2
    [dags_skrad] => May 21 2003  2:09PM
    [sidast_breytt] => May 21 2003  2:10PM
    [dags_deadline] =>
    [birt_vegna] => 1
)

The procedure returns 4 resultsets, and for the parameter tested, the first one is, and should be an empty set.

Arnar

>>> ArnarB at oddi.is 22.5.2003 16:01:31 >>>
Hello there..

I'm running a stored procedure on mssql server 2000 through php. The
stored procedure returns (in all cases) four result sets. Now.. I use
php's mssql_next_result, which in turn calls dbresults in the normal
way, to process each result set. The problem is that when one result
set, say the second one, contains no rows, mssql_next_result goes
straight to result set #3. I suspect that this is not normal behaviour,
correct me if I'm wrong.

I haven't stepped through the code yet, but a quick look indicates that
php's mssql_next_result is correct, at least according to ms
documentation on db-lib.

Have any of you heard of this before?

Arnar
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org 
http://lists.ibiblio.org/mailman/listinfo/freetds




More information about the FreeTDS mailing list