1
1
The following configuration is used to access MSSQL servers
2
a) PDO_ODBC (PhP 5.2.6 + fixes)
4
c) FreeTDS (0.82 + fixes)
8
a) PhP PDO/ODBC driver incorrectly handles long binary fields in the queries
9
(resulting in "Out of memory" error). This is a fix. Php bug #42765
10
http://dside.dyndns.org/projects/patches.dir/php-ds-odbc_blob.patch
9
- PhP PDO/ODBC driver incorrectly handles long binary fields in the queries
10
(resulting in "Out of memory" error). This is a fix. Php bug #42765.
11
The patch against php-5.2.6 (mandatory if BLOB data is used):
12
http://dside.dyndns.org/projects/patches.dir/php-ds-odbc_blob.patch
12
b) unixODBC (at least up to 2.2.12) expects pointer on 32 bit interger as
14
- unixODBC (at least up to 2.2.12) expects pointer on 32 bit interger as
13
15
last parameter of SQLBindCol call (MSDN defines SQLLEN). However, the php
14
16
on Linux 64 bit platform is passing 64 bit integer. This causes crash.
16
http://dside.dyndns.org/projects/patches.dir/php-ds-odbc64.patch
18
c) FreeTDS (at least up to 0.82) ODBC driver is corrupting data if
19
SQLGetData is called multiple times on a single column and
20
BINARY->CHAR data conversion have been involved.
21
http://dside.dyndns.org/projects/patches.dir/freetds-0.82-odbc-csa2.patch
23
d) PHP PDO/ODBC driver doesn't support PDO::ATTR_TIMEOUT attribute and,
24
therefore it takes too long to detect inaccessible servers.
26
http://dside.dyndns.org/projects/patches.dir/php-ds-odbc_timeout.patch
17
Unfortunately, it is really hard work to fix it on unixODBC side (expected in
18
2.2.13). Therefore, the parts of the problem which is involving PDO/ODBC
19
misbehaviour is fixed on PhP side.
20
The patch against php-5.2.6 (mandatory):
21
http://dside.dyndns.org/projects/patches.dir/php-ds-odbc64.patch
23
- FreeTDS (0.82 and earlier) ODBC driver is corrupting data if SQLGetData is
24
called multiple times on a single column and BINARY->CHAR data conversion
26
The patch agains FreeTDS-0.82 (mandatory if BLOB data bigger than 512 bytes
28
http://dside.dyndns.org/projects/patches.dir/freetds-0.82-odbc-csa2.patch
32
- PhP (5.2.6 and earlier) PDO/ODBC driver is ignoring PDO::ATTR_TIMEOUT
33
attribute, what causes extremly long delays trying to access dead / unreachable
34
servers. Php bug #45287.
35
The patch agains php-5.2.6 (optional, recommended):
36
http://dside.dyndns.org/projects/patches.dir/php-ds-odbc_timeout.patch
28
e) FreeTDS uses SQL_ATTR_CONNECTION_TIMEOUT instead SQL_ATTR_LOGIN_TIMEOUT
38
- FreeTDS uses SQL_ATTR_CONNECTION_TIMEOUT instead SQL_ATTR_LOGIN_TIMEOUT
29
39
on connection initialization. This do not causing big problems, but
30
40
violites ODBC specification.
41
The patch against php-5.2.6 (optional):
31
42
http://dside.dyndns.org/projects/patches.dir/freetds-ds-connect_timeout.patch
33
f) Be aware what PDO/ODBC returns BINARY blobs converted to ASCII hexdecimal
44
- Be aware what PDO/ODBC returns BINARY blobs converted to ASCII hexdecimal
34
45
representation. I decieded against patching this behaviour in driver code,
35
46
but just taking care in php code.
36
47
However, to insert data in the binary blob, it is neccesary to provide the
37
48
data in binary form.
52
- PhP (5.2.6) PDO/ODBC driver incorrectly handles PDO::PARAM_LOB parameters if
53
$length attribute is set. No fix is available upto now, just avoid setting the
56
- Either PDO/ODBC module or FreeTDS is sending all the data (with exception of
57
PDO::PARAM_LOB) to MSSQL server using TEXT variables. However, MSSQL is not
58
able to make implicit conversion of TEXT variables.
59
This causes troubles while writing INSERT queries. The problem could be
60
avoided by making explicit conversion to size-limit CHAR type in INSERT
62
INSERT INTO ... (intcol) VALUE(CONVERT(CHAR(64), ?));
64
- after 'prepare' call, the query (at least INSERT one) could be 'execute'
65
only 65535 times. Afterwars, strange excpetion is emerges. Just repraparing
66
is not helpful. It's necessary to close PDO connection and open it again.
70
- Inserting the datetime values into MSSQL database is quite tricky, I'm
71
using following procedure:
72
* Setting date format:
73
$dbh->query("set dateformat ymd");
74
* Formating date string:
75
$sqltime = strftime("%Y-%m-%d %H:%M:%S", floor($tm));
76
* Preparing SQL query:
77
... VALUES( ... CONVERT(DATETIME, CONVERT(CHAR(20), ?), 111) ... ) ...
41
82
- FreeTDS ODBC driver is not implementing SQLDescribeType interface. Therefore,