Francesco Venturini Thu May 22 10:28:09 -0400 2014

Subject: so no microsoft sqlsrv

Finally, there is no way to use microsoft sql server ?


Ladislav Gallay Sat May 24 19:24:43 -0400 2014

Hi, I would also like to use microsoft sql (MSSQL). Can anyone help us or give us hint how to edit adapter file to get it work with MSSQL?

Thank you very much!

Ladislav Gallay Sun May 25 04:41:50 -0400 2014

Hi Francesco and anyone else,

I talked to funkjedi (former author of sql adapter) and he put his code back to GitHub and there's open pull request (https://github.com/jpfuentes2/php-activerecord/pull/409)

Here is the code:
https://github.com/funkjedi/php-activerecord/tree/feature-sqlsrv

Enjoy!

Francesco Venturini Mon May 26 05:31:53 -0400 2014

thanks
I am going to test this with my SQL
I will post any news from me in a few hours

Ladislav Gallay Mon May 26 05:38:04 -0400 2014

I had some problems with it, but I fixed it. I am using SQL 2014 Server. In SqlsrvAdapter.php:

Add
static $datetime_format = 'Y-m-d H:i:s';
This overrides default datetime_format in Model. There is T (Timezone abbreviation) but SQL don't accept it.

In method query_column_info I changed following:
$sql = "SELECT c.COLUMN_NAME as field, c.DATA_TYPE as data_type, c.CHARACTER_MAXIMUM_LENGTH AS length, c.NUMERIC_PRECISION_RADIX AS radix, c.COLUMN_DEFAULT AS data_default, c.IS_NULLABLE AS nullable, " . "COLUMNPROPERTY(OBJECT_ID(TABLE_NAME), c.COLUMN_NAME, 'IsIdentity') AS extra, " . "(SELECT TOP 1 a.CONSTRAINT_TYPE " . "FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS a, INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE b " . "WHERE a.CONSTRAINT_TYPE='PRIMARY KEY' " . "AND a.CONSTRAINT_NAME = b.CONSTRAINT_NAME " . "AND a.TABLE_NAME = b.TABLE_NAME AND b.COLUMN_NAME = c.COLUMN_NAME) AS PK " . "FROM INFORMATION_SCHEMA.COLUMNS c " . "WHERE c.TABLE_NAME=?";

I added SELECT TOP 1 because it was returning multiple lines and throws SQL error.
It should works now.

(1-4/4)