MSSQL returning wrong result
3 posts
• Page 1 of 1
MSSQL returning wrong result
I discovered something weird with the managed MSSQL extension.
When I use mssql_connect('host,1344', 'user', 'pass') providing a port number, after some queries, mssql_fetch_assoc() returns a wrong result = array("computed" => 1) instead if a valid result.
When I connect using mssql_connect('host', 'user', 'pass') without the port, it always works as expected.
I will now provide more details in order to guess what could be the reason for this weird behaviour:
1) For this code...
...the result fails each 3 times (always) returning array('computed' => 1) for any $sql.
2) For this code...
...the result fails each 3 times (always) returning NULL for any $sql.
3) For this code...
...it "never" fails (I tried about 20 times).
4) For this code...
...the result fails each 3 times (always) returning array('computed' => 1) for any $sql.
5) For this code...
...it "never" fails (I tried about 20 times).
6) If I repeat the query (in the same request / connection) many times...
...it only fails each 3 requests for the first query, but not the other ones.
Remarks:
It seems like it is related with the fact that I'm providing a port number ("host,port") and using mssql_select_db('dbname').
I'm running this code on Mono (Mono JIT compiler version 2.11.4) on CentOS Linux.
I don't have problems accessing the SQL Server with "host" or "host,port" from MS Visual Studio's Database Explorer.
Any idea what could be the problem?
When I use mssql_connect('host,1344', 'user', 'pass') providing a port number, after some queries, mssql_fetch_assoc() returns a wrong result = array("computed" => 1) instead if a valid result.
When I connect using mssql_connect('host', 'user', 'pass') without the port, it always works as expected.
I will now provide more details in order to guess what could be the reason for this weird behaviour:
1) For this code...
- Code: Select all
mssql_pconnect($host . ',' . $port, $user, $pass);
mssql_select_db($db);
mssql_query("SET DATEFORMAT ymd");
$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);
...the result fails each 3 times (always) returning array('computed' => 1) for any $sql.
2) For this code...
- Code: Select all
mssql_pconnect($host . ',' . $port, $user, $pass);
mssql_select_db($db);
// mssql_query("SET DATEFORMAT ymd");
$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);
...the result fails each 3 times (always) returning NULL for any $sql.
3) For this code...
- Code: Select all
mssql_pconnect($host . ',' . $port, $user, $pass);
// mssql_select_db($db);
// mssql_query("SET DATEFORMAT ymd");
$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);
...it "never" fails (I tried about 20 times).
4) For this code...
- Code: Select all
mssql_pconnect($host . ',' . $port, $user, $pass);
// mssql_select_db($db);
mssql_query("SET DATEFORMAT ymd");
$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);
...the result fails each 3 times (always) returning array('computed' => 1) for any $sql.
5) For this code...
- Code: Select all
mssql_pconnect($host, $user, $pass);
mssql_select_db($db);
mssql_query("SET DATEFORMAT ymd");
$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);
...it "never" fails (I tried about 20 times).
6) If I repeat the query (in the same request / connection) many times...
- Code: Select all
mssql_pconnect($host . ',' . $port, $user, $pass);
mssql_select_db($db);
mssql_query("SET DATEFORMAT ymd");
// Result will only fail here each 3 requests
$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);
// It "never" fails here
$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);
// Nor here
$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);
...
...it only fails each 3 requests for the first query, but not the other ones.
Remarks:
It seems like it is related with the fact that I'm providing a port number ("host,port") and using mssql_select_db('dbname').
I'm running this code on Mono (Mono JIT compiler version 2.11.4) on CentOS Linux.
I don't have problems accessing the SQL Server with "host" or "host,port" from MS Visual Studio's Database Explorer.
Any idea what could be the problem?
- kripper
- Posts: 44
- Joined: February 19th, 2012, 1:02 am
Re: MSSQL returning wrong result
As I know, port number should be specified after ':' character.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: MSSQL returning wrong result
1) Separating port with ':' worked fine for Windows with php_dblib.dll and Linux with php_mssql.so.
But with Phalanger on Mono, ':' doesn't work, but ',' works fine.
I will take a look at mono's SQL implementation when I have some time.
2) I noticed that the even when not passing the port, the issue is still present, but less frequent.
Please, ignore/close this ticket, since it is probably not related with Phalanger but other components.
Thanks.
But with Phalanger on Mono, ':' doesn't work, but ',' works fine.
I will take a look at mono's SQL implementation when I have some time.
2) I noticed that the even when not passing the port, the issue is still present, but less frequent.
Please, ignore/close this ticket, since it is probably not related with Phalanger but other components.
Thanks.
- kripper
- Posts: 44
- Joined: February 19th, 2012, 1:02 am
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 15 guests